1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.util;
11
12 import static org.junit.Assert.assertEquals;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.junit.Before;
18 import org.junit.Test;
19
20 public class ReadLinesTest {
21 List<String> l = new ArrayList<>();
22
23 @Before
24 public void clearList() {
25 l.clear();
26 }
27
28 @Test
29 public void testReadLines_singleLine() {
30 l.add("[0]");
31 assertEquals(l, IO.readLines("[0]"));
32 }
33
34 @Test
35 public void testReadLines_LF() {
36 l.add("[0]");
37 l.add("[1]");
38 assertEquals(l, IO.readLines("[0]\n[1]"));
39 }
40
41 @Test
42 public void testReadLines_CRLF() {
43 l.add("[0]");
44 l.add("[1]");
45 assertEquals(l, IO.readLines("[0]\r\n[1]"));
46 }
47
48 @Test
49 public void testReadLines_endLF() {
50 l.add("[0]");
51 l.add("");
52 assertEquals(l, IO.readLines("[0]\n"));
53 }
54
55 @Test
56 public void testReadLines_endCRLF() {
57 l.add("[0]");
58 l.add("");
59 assertEquals(l, IO.readLines("[0]\r\n"));
60 }
61
62 @Test
63 public void testReadLines_mixed() {
64 l.add("[0]");
65 l.add("[1]");
66 l.add("[2]");
67 assertEquals(l, IO.readLines("[0]\r\n[1]\n[2]"));
68 }
69 }