|
@@ -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
|
+}
|