|
@@ -1,74 +1,74 @@
|
1
|
|
-//package Pair;
|
2
|
|
-//
|
3
|
|
-//import org.junit.Assert;
|
4
|
|
-//import org.junit.Test;
|
5
|
|
-//
|
6
|
|
-//import java.util.ArrayList;
|
7
|
|
-//
|
8
|
|
-//public class ArraysTest {
|
9
|
|
-// @Test
|
10
|
|
-// public void firstLast() throws Exception {
|
11
|
|
-// // Given an ArrayList of Integers
|
12
|
|
-// ArrayList<Integer> al = new ArrayList<>();
|
13
|
|
-// al.add(1);
|
14
|
|
-// al.add(5);
|
15
|
|
-// al.add(3);
|
16
|
|
-// al.add(4);
|
17
|
|
-// al.add(2);
|
18
|
|
-// al.add(0);
|
19
|
|
-// al.add(1000);
|
20
|
|
-// // When firstLast is called
|
21
|
|
-// Pair<Integer> result = Arrays.firstLast(al);
|
22
|
|
-// // Then it should return the first and last items
|
23
|
|
-// Assert.assertEquals(new Integer(1), result.getFirst());
|
24
|
|
-// Assert.assertEquals(new Integer(1000), result.getSecond());
|
25
|
|
-// }
|
26
|
|
-//
|
27
|
|
-// @Test
|
28
|
|
-// public void testMin() throws Exception {
|
29
|
|
-// // Given an ArrayList of Integers
|
30
|
|
-// ArrayList<Integer> al = new ArrayList<>();
|
31
|
|
-// al.add(1);
|
32
|
|
-// al.add(5);
|
33
|
|
-// al.add(3);
|
34
|
|
-// al.add(4);
|
35
|
|
-// al.add(2);
|
36
|
|
-// al.add(0);
|
37
|
|
-// al.add(1000);
|
38
|
|
-// // When min is called assert that it gets the smallest item
|
39
|
|
-// Assert.assertEquals(new Integer(0), Arrays.min(al));
|
40
|
|
-// }
|
41
|
|
-//
|
42
|
|
-// @Test
|
43
|
|
-// public void testMax() throws Exception {
|
44
|
|
-// // Given an ArrayList of Integers
|
45
|
|
-// ArrayList<Integer> al = new ArrayList<>();
|
46
|
|
-// al.add(1);
|
47
|
|
-// al.add(5);
|
48
|
|
-// al.add(3);
|
49
|
|
-// al.add(4);
|
50
|
|
-// al.add(2);
|
51
|
|
-// al.add(0);
|
52
|
|
-// al.add(1000);
|
53
|
|
-// // When min is called assert that it gets the largest item
|
54
|
|
-// Assert.assertEquals(new Integer(1000), Arrays.max(al));
|
55
|
|
-// }
|
56
|
|
-//
|
57
|
|
-// @Test
|
58
|
|
-// public void testMinMax() throws Exception {
|
59
|
|
-// // Given an ArrayList of Integers
|
60
|
|
-// ArrayList<Integer> al = new ArrayList<>();
|
61
|
|
-// al.add(1);
|
62
|
|
-// al.add(5);
|
63
|
|
-// al.add(3);
|
64
|
|
-// al.add(4);
|
65
|
|
-// al.add(2);
|
66
|
|
-// al.add(0);
|
67
|
|
-// al.add(1000);
|
68
|
|
-// // When minMax is called
|
69
|
|
-// Pair<Integer> result = Arrays.minMax(al);
|
70
|
|
-// // Then it should return the first and last items
|
71
|
|
-// Assert.assertEquals(new Integer(0), result.min());
|
72
|
|
-// Assert.assertEquals(new Integer(1000), result.max());
|
73
|
|
-// }
|
74
|
|
-//}
|
|
1
|
+package Pair;
|
|
2
|
+
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Test;
|
|
5
|
+
|
|
6
|
+import java.util.ArrayList;
|
|
7
|
+
|
|
8
|
+public class ArraysTest {
|
|
9
|
+ @Test
|
|
10
|
+ public void firstLast() throws Exception {
|
|
11
|
+ // Given an ArrayList of Integers
|
|
12
|
+ ArrayList<Integer> al = new ArrayList<>();
|
|
13
|
+ al.add(1);
|
|
14
|
+ al.add(5);
|
|
15
|
+ al.add(3);
|
|
16
|
+ al.add(4);
|
|
17
|
+ al.add(2);
|
|
18
|
+ al.add(0);
|
|
19
|
+ al.add(1000);
|
|
20
|
+ // When firstLast is called
|
|
21
|
+ Pair<Integer> result = Arrays.firstLast(al);
|
|
22
|
+ // Then it should return the first and last items
|
|
23
|
+ Assert.assertEquals(new Integer(1), result.getFirst());
|
|
24
|
+ Assert.assertEquals(new Integer(1000), result.getSecond());
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ @Test
|
|
28
|
+ public void testMin() throws Exception {
|
|
29
|
+ // Given an ArrayList of Integers
|
|
30
|
+ ArrayList<Integer> al = new ArrayList<>();
|
|
31
|
+ al.add(1);
|
|
32
|
+ al.add(5);
|
|
33
|
+ al.add(3);
|
|
34
|
+ al.add(4);
|
|
35
|
+ al.add(2);
|
|
36
|
+ al.add(0);
|
|
37
|
+ al.add(1000);
|
|
38
|
+ // When min is called assert that it gets the smallest item
|
|
39
|
+ Assert.assertEquals(new Integer(0), Arrays.min(al));
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ @Test
|
|
43
|
+ public void testMax() throws Exception {
|
|
44
|
+ // Given an ArrayList of Integers
|
|
45
|
+ ArrayList<Integer> al = new ArrayList<>();
|
|
46
|
+ al.add(1);
|
|
47
|
+ al.add(5);
|
|
48
|
+ al.add(3);
|
|
49
|
+ al.add(4);
|
|
50
|
+ al.add(2);
|
|
51
|
+ al.add(0);
|
|
52
|
+ al.add(1000);
|
|
53
|
+ // When min is called assert that it gets the largest item
|
|
54
|
+ Assert.assertEquals(new Integer(1000), Arrays.max(al));
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ @Test
|
|
58
|
+ public void testMinMax() throws Exception {
|
|
59
|
+ // Given an ArrayList of Integers
|
|
60
|
+ ArrayList<Integer> al = new ArrayList<>();
|
|
61
|
+ al.add(1);
|
|
62
|
+ al.add(5);
|
|
63
|
+ al.add(3);
|
|
64
|
+ al.add(4);
|
|
65
|
+ al.add(2);
|
|
66
|
+ al.add(0);
|
|
67
|
+ al.add(1000);
|
|
68
|
+ // When minMax is called
|
|
69
|
+ Pair<Integer> result = Arrays.minMax(al);
|
|
70
|
+ // Then it should return the first and last items
|
|
71
|
+ Assert.assertEquals(new Integer(0), result.min());
|
|
72
|
+ Assert.assertEquals(new Integer(1000), result.max());
|
|
73
|
+ }
|
|
74
|
+}
|