Leon hace 5 años
padre
commit
411f262d67

+ 8
- 0
src/main/java/rocks/zipcode/quiz5/arrays/ArrayUtils.java Ver fichero

@@ -11,4 +11,12 @@ public class ArrayUtils {
11 11
     public static String[] removeMiddleElement(String[] values) {
12 12
         return null;
13 13
     }
14
+
15
+    public static String getLastElement(String[] values) {
16
+        return null;
17
+    }
18
+
19
+    public static String removeLastElement(String[] values) {
20
+        return null;
21
+    }
14 22
 }

+ 52
- 0
src/test/java/rocks/zipcode/quiz5/arrays/arrayutils/GetLastElementTest.java Ver fichero

@@ -0,0 +1,52 @@
1
+package rocks.zipcode.quiz5.arrays.arrayutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz5.arrays.ArrayUtils;
6
+
7
+/**
8
+ * @author leon on 02/01/2019.
9
+ */
10
+public class GetLastElementTest {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        String expected = "Dog";
15
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps", "Over", "The", "Lazy", expected};
16
+        test(expected, input);
17
+    }
18
+
19
+    @Test
20
+    public void test2() {
21
+        // given
22
+        String expected = "Lazy";
23
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps", "Over", "The", expected};
24
+        test(expected, input);
25
+    }
26
+
27
+
28
+    @Test
29
+    public void test3() {
30
+        // given
31
+        String expected = "The";
32
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps", "Over", expected};
33
+        test(expected, input);
34
+    }
35
+
36
+
37
+    @Test
38
+    public void test4() {
39
+        // given
40
+        String expected = "Over";
41
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps", expected};
42
+        test(expected, input);
43
+    }
44
+
45
+    private void test(String expected, String[] input) {
46
+        // when
47
+        String actual = ArrayUtils.getLastElement(input);
48
+
49
+        //then
50
+        Assert.assertEquals(expected, actual);
51
+    }
52
+}

+ 0
- 1
src/test/java/rocks/zipcode/quiz5/arrays/arrayutils/GetMiddleElementTest.java Ver fichero

@@ -31,7 +31,6 @@ public class GetMiddleElementTest {
31 31
         test(expected, input);
32 32
     }
33 33
 
34
-
35 34
     @Test
36 35
     public void test4() {
37 36
         // given

+ 52
- 0
src/test/java/rocks/zipcode/quiz5/arrays/arrayutils/RemoveLastElementTest.java Ver fichero

@@ -0,0 +1,52 @@
1
+package rocks.zipcode.quiz5.arrays.arrayutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz5.arrays.ArrayUtils;
6
+
7
+/**
8
+ * @author leon on 02/01/2019.
9
+ */
10
+public class RemoveLastElementTest {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        String[] expected = {"The", "Quick"};
15
+        String[] input = {"The", "Quick", "Brown"};
16
+        test(expected, input);
17
+
18
+    }
19
+
20
+    @Test
21
+    public void test2() {
22
+        // given
23
+        String[] expected = {"The", "Quick", "Brown", "Fox"};
24
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps"};
25
+        test(expected, input);
26
+    }
27
+
28
+    @Test
29
+    public void test3() {
30
+        // given
31
+        String[] expected = {"The", "Quick", "Brown", "Fox", "Jumps", "Over"};
32
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps", "Over", "The"};
33
+        test(expected, input);
34
+    }
35
+
36
+
37
+    @Test
38
+    public void test4() {
39
+        // given
40
+        String[] expected = {"The", "Quick", "Brown", "Fox", "Jumps", "Over", "The", "Lazy"};
41
+        String[] input = {"The", "Quick", "Brown", "Fox", "Jumps", "Over", "The", "Lazy", "Dog"};
42
+        test(expected, input);
43
+    }
44
+
45
+    private void test(String[] expected, String[] input) {
46
+        // when
47
+        String[] actual = ArrayUtils.removeMiddleElement(input);
48
+
49
+        //then
50
+        Assert.assertArrayEquals(expected, actual);
51
+    }
52
+}

src/test/java/rocks/zipcode/quiz5/arrays/arrayutils/RemoveMiddleCharacterTest.java → src/test/java/rocks/zipcode/quiz5/arrays/arrayutils/RemoveMiddleElementTest.java Ver fichero

@@ -4,7 +4,7 @@ import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 import rocks.zipcode.quiz5.arrays.ArrayUtils;
6 6
 
7
-public class RemoveMiddleCharacterTest {
7
+public class RemoveMiddleElementTest {
8 8
     @Test
9 9
     public void test1() {
10 10
         // given