|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+import org.junit.Ignore;
|
|
|
2
|
+import org.junit.Test;
|
|
|
3
|
+
|
|
|
4
|
+import java.util.ArrayList;
|
|
|
5
|
+import java.util.Arrays;
|
|
|
6
|
+import java.util.Collections;
|
|
|
7
|
+import java.util.List;
|
|
|
8
|
+
|
|
|
9
|
+import static org.junit.Assert.assertEquals;
|
|
|
10
|
+
|
|
|
11
|
+public class MatrixTest {
|
|
|
12
|
+
|
|
|
13
|
+ @Test
|
|
|
14
|
+ public void testCanIdentifySingleSaddlePoint() {
|
|
|
15
|
+ Matrix matrix = new Matrix(Arrays.asList(
|
|
|
16
|
+ Arrays.asList(9, 8, 7),
|
|
|
17
|
+ Arrays.asList(5, 3, 2),
|
|
|
18
|
+ Arrays.asList(6, 6, 7)
|
|
|
19
|
+ ));
|
|
|
20
|
+
|
|
|
21
|
+ List<MatrixCoordinate> expectedSaddlePoints = Collections.singletonList(new MatrixCoordinate(1, 0));
|
|
|
22
|
+
|
|
|
23
|
+ assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
|
|
24
|
+ }
|
|
|
25
|
+
|
|
|
26
|
+ @Ignore
|
|
|
27
|
+ @Test
|
|
|
28
|
+ public void testCanIdentifyThatEmptyMatrixHasNoSaddlePoints() {
|
|
|
29
|
+ Matrix matrix = new Matrix(new ArrayList<>());
|
|
|
30
|
+
|
|
|
31
|
+ List<MatrixCoordinate> expectedSaddlePoints = new ArrayList<>();
|
|
|
32
|
+
|
|
|
33
|
+ assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
|
|
34
|
+ }
|
|
|
35
|
+
|
|
|
36
|
+ @Ignore
|
|
|
37
|
+ @Test
|
|
|
38
|
+ public void testCanIdentifyLackOfSaddlePointsWhenThereAreNone() {
|
|
|
39
|
+ Matrix matrix = new Matrix(Arrays.asList(
|
|
|
40
|
+ Arrays.asList(1, 2, 3),
|
|
|
41
|
+ Arrays.asList(3, 1, 2),
|
|
|
42
|
+ Arrays.asList(2, 3, 1)
|
|
|
43
|
+ ));
|
|
|
44
|
+
|
|
|
45
|
+ List<MatrixCoordinate> expectedSaddlePoints = new ArrayList<>();
|
|
|
46
|
+
|
|
|
47
|
+ assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
|
|
48
|
+ }
|
|
|
49
|
+
|
|
|
50
|
+ @Ignore
|
|
|
51
|
+ @Test
|
|
|
52
|
+ public void testCanIdentifyMultipleSaddlePoints() {
|
|
|
53
|
+ Matrix matrix = new Matrix(Arrays.asList(
|
|
|
54
|
+ Arrays.asList(4, 5, 4),
|
|
|
55
|
+ Arrays.asList(3, 5, 5),
|
|
|
56
|
+ Arrays.asList(1, 5, 4)
|
|
|
57
|
+ ));
|
|
|
58
|
+
|
|
|
59
|
+ List<MatrixCoordinate> expectedSaddlePoints = Arrays.asList(
|
|
|
60
|
+ new MatrixCoordinate(0, 1),
|
|
|
61
|
+ new MatrixCoordinate(1, 1),
|
|
|
62
|
+ new MatrixCoordinate(2, 1)
|
|
|
63
|
+ );
|
|
|
64
|
+
|
|
|
65
|
+ assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
|
68
|
+ @Ignore
|
|
|
69
|
+ @Test
|
|
|
70
|
+ public void testCanIdentifySaddlePointInBottomRightCorner() {
|
|
|
71
|
+ Matrix matrix = new Matrix(Arrays.asList(
|
|
|
72
|
+ Arrays.asList(8, 7, 9),
|
|
|
73
|
+ Arrays.asList(6, 7, 6),
|
|
|
74
|
+ Arrays.asList(3, 2, 5)
|
|
|
75
|
+ ));
|
|
|
76
|
+
|
|
|
77
|
+ List<MatrixCoordinate> expectedSaddlePoints = Collections.singletonList(new MatrixCoordinate(2, 2));
|
|
|
78
|
+
|
|
|
79
|
+ assertEquals(expectedSaddlePoints, matrix.getSaddlePoints());
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
|
82
|
+}
|