Leon Hunter 5 лет назад
Родитель
Сommit
7a85def74a

+ 7
- 0
src/main/java/rocks/zipcode/quiz3a/arrays/ArrayUtils.java Просмотреть файл

@@ -4,4 +4,11 @@ package rocks.zipcode.quiz3a.arrays;
4 4
  * @author leon on 01/01/2019.
5 5
  */
6 6
 public class ArrayUtils {
7
+    public static String getMiddleElement(String[] values) {
8
+        return null;
9
+    }
10
+
11
+    public static String[] removeMiddleElement(String[] values) {
12
+        return null;
13
+    }
7 14
 }

+ 47
- 0
src/test/java/rocks/zipcode/quiz3a/arrays/arrayutils/GetMiddleElementTest.java Просмотреть файл

@@ -0,0 +1,47 @@
1
+package rocks.zipcode.quiz3a.arrays.arrayutils;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.arrays.ArrayUtils;
6
+
7
+public class GetMiddleElementTest {
8
+    @Test
9
+    public void test1() {
10
+        // given
11
+        String expected = "Quick";
12
+        String[] strings = {"The", expected, "Brown"};
13
+
14
+        // when
15
+        String actual = ArrayUtils.getMiddleElement(strings);
16
+
17
+        //then
18
+        Assert.assertEquals(expected, actual);
19
+    }
20
+
21
+    @Test
22
+    public void test2() {
23
+        // given
24
+        String expected = "Brown";
25
+        String[] strings = {"The", "Quick", expected, "Fox", "Jumps"};
26
+
27
+        // when
28
+        String actual = ArrayUtils.getMiddleElement(strings);
29
+
30
+        //then
31
+        Assert.assertEquals(expected, actual);
32
+    }
33
+
34
+
35
+    @Test
36
+    public void test3() {
37
+        // given
38
+        String expected = "Fox";
39
+        String[] strings = {"The", "Quick", "Brown", expected, "Jumps", "Over", "The"};
40
+
41
+        // when
42
+        String actual = ArrayUtils.getMiddleElement(strings);
43
+
44
+        //then
45
+        Assert.assertEquals(expected, actual);
46
+    }
47
+}

+ 47
- 0
src/test/java/rocks/zipcode/quiz3a/arrays/arrayutils/RemoveMiddleCharacterTest.java Просмотреть файл

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