1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 package org.eclipse.jgit.util;
45
46 import static org.junit.Assert.assertEquals;
47 import static org.junit.Assert.assertFalse;
48 import static org.junit.Assert.assertTrue;
49
50 import org.junit.Test;
51
52 public class StringUtilsTest {
53 @Test
54 public void testToLowerCaseChar() {
55 assertEquals('a', StringUtils.toLowerCase('A'));
56 assertEquals('z', StringUtils.toLowerCase('Z'));
57
58 assertEquals('a', StringUtils.toLowerCase('a'));
59 assertEquals('z', StringUtils.toLowerCase('z'));
60
61 assertEquals((char) 0, StringUtils.toLowerCase((char) 0));
62 assertEquals((char) 0xffff, StringUtils.toLowerCase((char) 0xffff));
63 }
64
65 @Test
66 public void testToLowerCaseString() {
67 assertEquals("\n abcdefghijklmnopqrstuvwxyz\n", StringUtils
68 .toLowerCase("\n ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"));
69 }
70
71 @Test
72 public void testEqualsIgnoreCase1() {
73 final String a = "FOO";
74 assertTrue(StringUtils.equalsIgnoreCase(a, a));
75 }
76
77 @Test
78 public void testEqualsIgnoreCase2() {
79 assertFalse(StringUtils.equalsIgnoreCase("a", ""));
80 }
81
82 @Test
83 public void testEqualsIgnoreCase3() {
84 assertFalse(StringUtils.equalsIgnoreCase("a", "b"));
85 assertFalse(StringUtils.equalsIgnoreCase("ac", "ab"));
86 }
87
88 @Test
89 public void testEqualsIgnoreCase4() {
90 assertTrue(StringUtils.equalsIgnoreCase("a", "a"));
91 assertTrue(StringUtils.equalsIgnoreCase("A", "a"));
92 assertTrue(StringUtils.equalsIgnoreCase("a", "A"));
93 }
94
95 @Test
96 public void testReplaceLineBreaks() {
97 assertEquals("a b c ",
98 StringUtils.replaceLineBreaksWithSpace("a b\nc\r"));
99 assertEquals("a b c ",
100 StringUtils.replaceLineBreaksWithSpace("a b\nc\n"));
101 assertEquals("a b c ",
102 StringUtils.replaceLineBreaksWithSpace("a b\nc\r\n"));
103 assertEquals("a b c d",
104 StringUtils.replaceLineBreaksWithSpace("a\r\nb\nc d"));
105 }
106 }