Sfoglia il codice sorgente

Merge https://git.zipcode.rocks/Cohort4.2/Quiz3

Nick Satinover 6 anni fa
parent
commit
1c09cfab3a

+ 52
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/stringutils/CapitalizeNthCharacter.java Vedi File

@@ -0,0 +1,52 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.stringutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.fundamentals.StringUtils;
6
+
7
+/**
8
+ * @author leon on 10/12/2018.
9
+ */
10
+public class CapitalizeNthCharacter {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        String input = "hello";
15
+        String expected = "Hello";
16
+        Integer indexToCapitalize = 0;
17
+
18
+        // when
19
+        String actual = StringUtils.capitalizeNthCharacter(input, indexToCapitalize);
20
+
21
+        // them
22
+        Assert.assertEquals(expected, actual);
23
+    }
24
+
25
+    @Test
26
+    public void test2() {
27
+        // given
28
+        String input = "hello";
29
+        String expected = "hEllo";
30
+        Integer indexToCapitalize = 1;
31
+
32
+        // when
33
+        String actual = StringUtils.capitalizeNthCharacter(input, indexToCapitalize);
34
+
35
+        // them
36
+        Assert.assertEquals(expected, actual);
37
+    }
38
+
39
+    @Test
40
+    public void test3() {
41
+        // given
42
+        String input = "hello";
43
+        String expected = "heLlo";
44
+        Integer indexToCapitalize = 2;
45
+
46
+        // when
47
+        String actual = StringUtils.capitalizeNthCharacter(input, indexToCapitalize);
48
+
49
+        // them
50
+        Assert.assertEquals(expected, actual);
51
+    }
52
+}

+ 14
- 12
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFilterTest.java Vedi File

@@ -1,7 +1,5 @@
1 1
 package rocks.zipcode.io.quiz3.generics.arrayutility.integer;
2 2
 
3
-import org.junit.Test;
4
-import rocks.zipcode.io.quiz3.TestUtils;
5 3
 import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6 4
 
7 5
 import java.util.function.Function;
@@ -10,7 +8,7 @@ import java.util.function.Function;
10 8
  * @author leon on 09/12/2018.
11 9
  */
12 10
 public class IntegerFilterTest {
13
-    @Test
11
+
14 12
     public void test1() {
15 13
         // given
16 14
         Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -22,10 +20,10 @@ public class IntegerFilterTest {
22 20
         Integer[] actual = utility.filter(predicate);
23 21
 
24 22
         // then
25
-        TestUtils.assertArrayEquals(expected, actual);
23
+        compare(expected, actual);
26 24
     }
27 25
 
28
-    @Test
26
+
29 27
     public void test2() {
30 28
         // given
31 29
         Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -37,10 +35,10 @@ public class IntegerFilterTest {
37 35
         Integer[] actual = utility.filter(predicate);
38 36
 
39 37
         // then
40
-        TestUtils.assertArrayEquals(expected, actual);
38
+        compare(expected, actual);
41 39
     }
42 40
 
43
-    @Test
41
+
44 42
     public void test3() {
45 43
         // given
46 44
         Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -52,10 +50,10 @@ public class IntegerFilterTest {
52 50
         Integer[] actual = utility.filter(predicate);
53 51
 
54 52
         // then
55
-        TestUtils.assertArrayEquals(expected, actual);
53
+        compare(expected, actual);
56 54
     }
57 55
 
58
-    @Test
56
+
59 57
     public void test4() {
60 58
         // given
61 59
         Integer[] array = new Integer[]{10, 15, 20, 25, 55, 100, 150, 300, 900, 1000};
@@ -67,10 +65,10 @@ public class IntegerFilterTest {
67 65
         Integer[] actual = utility.filter(predicate);
68 66
 
69 67
         // then
70
-        TestUtils.assertArrayEquals(expected, actual);
68
+        compare(expected, actual);
71 69
     }
72 70
 
73
-    @Test
71
+
74 72
     public void test5() {
75 73
         // given
76 74
         Integer[] array = new Integer[]{10, 15, 20, 25, 55, 100, 150, 300, 900, 1000};
@@ -82,6 +80,10 @@ public class IntegerFilterTest {
82 80
         Integer[] actual = utility.filter(predicate);
83 81
 
84 82
         // then
85
-        TestUtils.assertArrayEquals(expected, actual);
83
+        compare(expected, actual);
84
+    }
85
+
86
+    private void compare(Integer[] expected, Integer[] actual) {
87
+//        TestUtils.assertArrayEquals(expected, actual);
86 88
     }
87 89
 }

+ 1
- 1
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerGetNumberOfOccurrences.java Vedi File

@@ -48,7 +48,7 @@ public class IntegerGetNumberOfOccurrences {
48 48
         ArrayUtility<Integer> utility = new ArrayUtility<>(array);
49 49
 
50 50
         // when
51
-        Integer actual = utility.findEvenOccurringValue();
51
+        Integer actual = utility.getNumberOfOccurrences(valueToEvaluate);
52 52
 
53 53
         // then
54 54
         Assert.assertEquals(expected, actual);

+ 3
- 3
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFilterTest.java Vedi File

@@ -8,7 +8,7 @@ import rocks.zipcode.io.quiz3.generics.ArrayUtility;
8 8
  * @author leon on 09/12/2018.
9 9
  */
10 10
 public class StringFilterTest {
11
-    @Test
11
+    
12 12
     public void test1() {
13 13
         // given
14 14
         String[] expected = {"quick", "brown", "jumps", "over", "lazy"};
@@ -22,7 +22,7 @@ public class StringFilterTest {
22 22
         TestUtils.assertArrayEquals(expected, actual);
23 23
     }
24 24
 
25
-    @Test
25
+    
26 26
     public void test2() {
27 27
         // given
28 28
         String[] expected = {"The", "fox", "the", "dog"};
@@ -36,7 +36,7 @@ public class StringFilterTest {
36 36
         TestUtils.assertArrayEquals(expected, actual);
37 37
     }
38 38
 
39
-    @Test
39
+    
40 40
     public void test3() {
41 41
         // given
42 42
         String[] expected = {"The", "over", "the"};

+ 3
- 3
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFindOddOccurringValueTest.java Vedi File

@@ -16,7 +16,7 @@ public class StringFindOddOccurringValueTest {
16 16
         ArrayUtility<String> utility = new ArrayUtility<>(array);
17 17
 
18 18
         // when
19
-        String actual = utility.findEvenOccurringValue();
19
+        String actual = utility.findOddOccurringValue();
20 20
         Assert.assertEquals(expected, actual);
21 21
     }
22 22
 
@@ -28,7 +28,7 @@ public class StringFindOddOccurringValueTest {
28 28
         ArrayUtility<String> utility = new ArrayUtility<>(array);
29 29
 
30 30
         // when
31
-        String actual = utility.findEvenOccurringValue();
31
+        String actual = utility.findOddOccurringValue();
32 32
         Assert.assertEquals(expected, actual);
33 33
     }
34 34
 
@@ -40,7 +40,7 @@ public class StringFindOddOccurringValueTest {
40 40
         ArrayUtility<String> utility = new ArrayUtility<>(array);
41 41
 
42 42
         // when
43
-        String actual = utility.findEvenOccurringValue();
43
+        String actual = utility.findOddOccurringValue();
44 44
         Assert.assertEquals(expected, actual);
45 45
     }
46 46
 }

+ 2
- 2
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringGetNumberOfOccurrencesTest.java Vedi File

@@ -37,13 +37,13 @@ public class StringGetNumberOfOccurrencesTest {
37 37
     @Test
38 38
     public void test3() {
39 39
         // given
40
-        Integer expectedd = 7;
40
+        Integer expected = 7;
41 41
         String stringToEvaluate = "Code";
42 42
         String[] array = {"Zip", "Zip", "Zip", "Zip", "Zip", "Zip", stringToEvaluate, stringToEvaluate, stringToEvaluate, stringToEvaluate, "Wilmington", "Wilmington", stringToEvaluate, stringToEvaluate, stringToEvaluate};
43 43
         ArrayUtility<String> utility = new ArrayUtility<>(array);
44 44
 
45 45
         // when
46 46
         Integer actual = utility.getNumberOfOccurrences(stringToEvaluate);
47
-        Assert.assertEquals(stringToEvaluate, actual);
47
+        Assert.assertEquals(expected, actual);
48 48
     }
49 49
 }