Leon Hunter 5 years ago
parent
commit
dbb2c3196d

+ 4
- 0
src/main/java/rocks/zipcode/quiz3a/fundamentals/StringUtils.java View File

27
     public static String removeConsecutiveDuplicateCharacters(String str) {
27
     public static String removeConsecutiveDuplicateCharacters(String str) {
28
         return null;
28
         return null;
29
     }
29
     }
30
+
31
+    public static String invertCasing(String str) {
32
+        return null;
33
+    }
30
 }
34
 }

+ 33
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/CapitalizeMiddleCharacterTest.java View File

1
+package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.fundamentals.StringUtils;
6
+
7
+public class CapitalizeMiddleCharacterTest {
8
+    @Test
9
+    public void test1() {
10
+        // given
11
+        String input = "o";
12
+        String expected = "O";
13
+
14
+        // when
15
+        String actual = StringUtils.capitalizeMiddleCharacter(input);
16
+
17
+        // then
18
+        Assert.assertEquals(expected, actual);
19
+    }
20
+
21
+    @Test
22
+    public void test2() {
23
+        // given
24
+        String input = "ooo";
25
+        String expected = "oOo";
26
+
27
+        // when
28
+        String actual = StringUtils.capitalizeMiddleCharacter(input);
29
+
30
+        // then
31
+        Assert.assertEquals(expected, actual);
32
+    }
33
+}

+ 34
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/GetMiddleCharacterTest.java View File

1
+package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.fundamentals.StringUtils;
6
+
7
+public class GetMiddleCharacterTest {
8
+    @Test
9
+    public void test1() {
10
+        // given
11
+        String input = "joint";
12
+        Character expected = 'i';
13
+
14
+        // when
15
+        Character actual = StringUtils.getMiddleCharacter(input);
16
+
17
+        // then
18
+        Assert.assertEquals(expected, actual);
19
+    }
20
+
21
+
22
+    @Test
23
+    public void test2() {
24
+        // given
25
+        String input = "burnt";
26
+        Character expected = 'r';
27
+
28
+        // when
29
+        Character actual = StringUtils.getMiddleCharacter(input);
30
+
31
+        // then
32
+        Assert.assertEquals(expected, actual);
33
+    }
34
+}

+ 31
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/HasDuplicateCharacterTest.java View File

1
+package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.fundamentals.StringUtils;
6
+
7
+public class HasDuplicateCharacterTest {
8
+    @Test
9
+    public void test1() {
10
+        String input = "Happy";
11
+        Assert.assertFalse(StringUtils.hasDuplicateCharacters(input));
12
+    }
13
+
14
+    @Test
15
+    public void test2() {
16
+        String input = "Fool";
17
+        Assert.assertTrue(StringUtils.hasDuplicateCharacters(input));
18
+    }
19
+
20
+    @Test
21
+    public void test3() {
22
+        String input = "George";
23
+        Assert.assertFalse(StringUtils.hasDuplicateCharacters(input));
24
+    }
25
+
26
+    @Test
27
+    public void test4() {
28
+        String input = "False";
29
+        Assert.assertFalse(StringUtils.hasDuplicateCharacters(input));
30
+    }
31
+}

+ 49
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/InvertCasingTest.java View File

1
+package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+import static rocks.zipcode.quiz3a.fundamentals.StringUtils.invertCasing;
7
+
8
+public class InvertCasingTest {
9
+    @Test
10
+    public void test0() {
11
+        String input = "a";
12
+        String expected = "A";
13
+        Assert.assertEquals(expected, invertCasing(input));
14
+    }
15
+
16
+    @Test
17
+    public void test1() {
18
+        String input = "Z";
19
+        String expected = "z";
20
+        Assert.assertEquals(expected, invertCasing(input));
21
+    }
22
+
23
+    @Test
24
+    public void test2() {
25
+        String expected = "This one is kind of tricky!";
26
+        Assert.assertEquals(expected, invertCasing(invertCasing(expected)));
27
+
28
+    }
29
+
30
+    @Test
31
+    public void test3() {
32
+        String input = "iNcReAsInG";
33
+        String expected = "InCrEaSiNg";
34
+        Assert.assertEquals(expected, invertCasing(input));
35
+    }
36
+
37
+    @Test
38
+    public void test4() {
39
+        String input = "No Big Deal!";
40
+        String expected = "nO bIG dEAL!";
41
+        Assert.assertEquals(expected, invertCasing(input));
42
+    }
43
+
44
+    @Test
45
+    public void test5() {
46
+        String expected = "#^@!&*$(%$";
47
+        Assert.assertEquals(expected, invertCasing(expected));
48
+    }
49
+}

+ 27
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/IsIsoGramTest.java View File

1
 package rocks.zipcode.quiz3a.fundamentals.stringutils;
1
 package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
 
2
 
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.fundamentals.StringUtils;
6
+
3
 public class IsIsoGramTest {
7
 public class IsIsoGramTest {
8
+    @Test
9
+    public void test1() {
10
+        String input = "Jump";
11
+        Assert.assertTrue(StringUtils.isIsogram(input));
12
+    }
13
+
14
+    @Test
15
+    public void test2() {
16
+        String input = "Jj";
17
+        Assert.assertTrue(StringUtils.isIsogram(input));
18
+    }
19
+
20
+    @Test
21
+    public void test3() {
22
+        String input = "Here";
23
+        Assert.assertFalse(StringUtils.isIsogram(input));
24
+    }
25
+
26
+    @Test
27
+    public void test4() {
28
+        String input = "Teared";
29
+        Assert.assertFalse(StringUtils.isIsogram(input));
30
+    }
4
 }
31
 }

+ 33
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/LowerCaseMiddleCharacterTest.java View File

1
+package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.fundamentals.StringUtils;
6
+
7
+public class LowerCaseMiddleCharacterTest {
8
+    @Test
9
+    public void test1() {
10
+        // given
11
+        String input = "O";
12
+        String expected = "o";
13
+
14
+        // when
15
+        String actual = StringUtils.capitalizeMiddleCharacter(input);
16
+
17
+        // then
18
+        Assert.assertEquals(expected, actual);
19
+    }
20
+
21
+    @Test
22
+    public void test2() {
23
+        // given
24
+        String input = "OOO";
25
+        String expected = "OoO";
26
+
27
+        // when
28
+        String actual = StringUtils.capitalizeMiddleCharacter(input);
29
+
30
+        // then
31
+        Assert.assertEquals(expected, actual);
32
+    }
33
+}

+ 33
- 0
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/RemoveDuplicateCharactersTest.java View File

1
+package rocks.zipcode.quiz3a.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.fundamentals.StringUtils;
6
+
7
+public class RemoveDuplicateCharactersTest {
8
+    @Test
9
+    public void test1() {
10
+        // given
11
+        String input = "Fool";
12
+        String expected = "Fl";
13
+
14
+        // when
15
+        String actual = StringUtils.removeConsecutiveDuplicateCharacters(input);
16
+
17
+        // then
18
+        Assert.assertEquals(expected, actual);
19
+    }
20
+
21
+    @Test
22
+    public void test2() {
23
+        // given
24
+        String input = "Mississippi";
25
+        String expected = "Miiii";
26
+
27
+        // when
28
+        String actual = StringUtils.removeConsecutiveDuplicateCharacters(input);
29
+
30
+        // then
31
+        Assert.assertEquals(expected, actual);
32
+    }
33
+}