|
|
@@ -12,102 +12,114 @@ public final class QueenAttackCalculatorTest {
|
|
12
|
12
|
|
|
13
|
13
|
@Test
|
|
14
|
14
|
public void testNoExceptionThrownIfBothQueenPositionsValid() {
|
|
15
|
|
- new QueenAttackCalculator(new int[]{2, 2}, new int[]{0, 7});
|
|
|
15
|
+ new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(0, 7));
|
|
16
|
16
|
}
|
|
17
|
17
|
|
|
18
|
18
|
@Ignore
|
|
19
|
19
|
@Test
|
|
20
|
20
|
public void testNullInputNotAllowed() {
|
|
21
|
21
|
expectedException.expect(IllegalArgumentException.class);
|
|
22
|
|
- expectedException.expectMessage("You must supply valid 2-dimensional coordinate arrays for both Queens.");
|
|
|
22
|
+ expectedException.expectMessage("You must supply valid board coordinates for both Queens.");
|
|
23
|
23
|
|
|
24
|
|
- new QueenAttackCalculator(null, new int[]{3, 4});
|
|
|
24
|
+ new QueenAttackCalculator(null, new BoardCoordinate(0, 7));
|
|
25
|
25
|
}
|
|
26
|
26
|
|
|
27
|
27
|
@Ignore
|
|
28
|
28
|
@Test
|
|
29
|
29
|
public void testNegativeRankNotAllowed() {
|
|
30
|
30
|
expectedException.expect(IllegalArgumentException.class);
|
|
31
|
|
- expectedException.expectMessage("Queens must both have positive rank.");
|
|
|
31
|
+ expectedException.expectMessage("Coordinate must have positive rank.");
|
|
32
|
32
|
|
|
33
|
|
- new QueenAttackCalculator(new int[]{-2, 2}, new int[]{2, 2});
|
|
|
33
|
+ new BoardCoordinate(-2, 2);
|
|
34
|
34
|
}
|
|
35
|
35
|
|
|
36
|
36
|
@Ignore
|
|
37
|
37
|
@Test
|
|
38
|
38
|
public void testRankGreaterThan7NotAllowed() {
|
|
39
|
39
|
expectedException.expect(IllegalArgumentException.class);
|
|
40
|
|
- expectedException.expectMessage("Queens must both have rank <= 7.");
|
|
|
40
|
+ expectedException.expectMessage("Coordinate must have rank <= 7.");
|
|
41
|
41
|
|
|
42
|
|
- new QueenAttackCalculator(new int[]{8, 4}, new int[]{1, 6});
|
|
|
42
|
+ new BoardCoordinate(8, 4);
|
|
43
|
43
|
}
|
|
44
|
44
|
|
|
45
|
45
|
@Ignore
|
|
46
|
46
|
@Test
|
|
47
|
47
|
public void testNegativeFileNotAllowed() {
|
|
48
|
48
|
expectedException.expect(IllegalArgumentException.class);
|
|
49
|
|
- expectedException.expectMessage("Queens must both have positive file.");
|
|
|
49
|
+ expectedException.expectMessage("Coordinate must have positive file.");
|
|
50
|
50
|
|
|
51
|
|
- new QueenAttackCalculator(new int[]{2, -2}, new int[]{5, 3});
|
|
|
51
|
+ new BoardCoordinate(2, -2);
|
|
52
|
52
|
}
|
|
53
|
53
|
|
|
54
|
54
|
@Ignore
|
|
55
|
55
|
@Test
|
|
56
|
56
|
public void testFileGreaterThan7NotAllowed() {
|
|
57
|
57
|
expectedException.expect(IllegalArgumentException.class);
|
|
58
|
|
- expectedException.expectMessage("Queens must both have file <= 7.");
|
|
|
58
|
+ expectedException.expectMessage("Coordinate must have file <= 7.");
|
|
59
|
59
|
|
|
60
|
|
- new QueenAttackCalculator(new int[]{4, 8}, new int[]{7, 4});
|
|
|
60
|
+ new BoardCoordinate(4, 8);
|
|
61
|
61
|
}
|
|
62
|
62
|
|
|
63
|
63
|
@Ignore
|
|
64
|
64
|
@Test
|
|
65
|
65
|
public void testQueensMustNotOccupyTheSameSquare() {
|
|
66
|
66
|
expectedException.expect(IllegalArgumentException.class);
|
|
67
|
|
- expectedException.expectMessage("Queens must not occupy the same square.");
|
|
|
67
|
+ expectedException.expectMessage("Queens may not occupy the same board coordinate.");
|
|
68
|
68
|
|
|
69
|
|
- new QueenAttackCalculator(new int[]{2, 2}, new int[]{2, 2});
|
|
|
69
|
+ new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(2, 2));
|
|
70
|
70
|
}
|
|
71
|
71
|
|
|
72
|
72
|
@Ignore
|
|
73
|
73
|
@Test
|
|
74
|
74
|
public void testQueensCanAttackOnTheSameRank() {
|
|
75
|
|
- final QueenAttackCalculator calculator = new QueenAttackCalculator(new int[]{2, 4}, new int[]{2, 6});
|
|
|
75
|
+ final QueenAttackCalculator calculator
|
|
|
76
|
+ = new QueenAttackCalculator(new BoardCoordinate(2, 4), new BoardCoordinate(2, 6));
|
|
|
77
|
+
|
|
76
|
78
|
assertTrue(calculator.canQueensAttackOneAnother());
|
|
77
|
79
|
}
|
|
78
|
80
|
|
|
79
|
81
|
@Ignore
|
|
80
|
82
|
@Test
|
|
81
|
83
|
public void testQueensCanAttackOnTheSameFile() {
|
|
82
|
|
- final QueenAttackCalculator calculator = new QueenAttackCalculator(new int[]{4, 5}, new int[]{2, 5});
|
|
|
84
|
+ final QueenAttackCalculator calculator
|
|
|
85
|
+ = new QueenAttackCalculator(new BoardCoordinate(4, 5), new BoardCoordinate(2, 5));
|
|
|
86
|
+
|
|
83
|
87
|
assertTrue(calculator.canQueensAttackOneAnother());
|
|
84
|
88
|
}
|
|
85
|
89
|
|
|
86
|
90
|
@Ignore
|
|
87
|
91
|
@Test
|
|
88
|
92
|
public void testQueensCanAttackOnFirstDiagonal() {
|
|
89
|
|
- final QueenAttackCalculator calculator = new QueenAttackCalculator(new int[]{2, 2}, new int[]{0, 4});
|
|
|
93
|
+ final QueenAttackCalculator calculator
|
|
|
94
|
+ = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(0, 4));
|
|
|
95
|
+
|
|
90
|
96
|
assertTrue(calculator.canQueensAttackOneAnother());
|
|
91
|
97
|
}
|
|
92
|
98
|
|
|
93
|
99
|
@Ignore
|
|
94
|
100
|
@Test
|
|
95
|
101
|
public void testQueensCanAttackOnSecondDiagonal() {
|
|
96
|
|
- final QueenAttackCalculator calculator = new QueenAttackCalculator(new int[]{2, 2}, new int[]{3, 1});
|
|
|
102
|
+ final QueenAttackCalculator calculator
|
|
|
103
|
+ = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(3, 1));
|
|
|
104
|
+
|
|
97
|
105
|
assertTrue(calculator.canQueensAttackOneAnother());
|
|
98
|
106
|
}
|
|
99
|
107
|
|
|
100
|
108
|
@Ignore
|
|
101
|
109
|
@Test
|
|
102
|
110
|
public void testQueensCanAttackOnThirdDiagonal() {
|
|
103
|
|
- final QueenAttackCalculator calculator = new QueenAttackCalculator(new int[]{2, 2}, new int[]{1, 1});
|
|
|
111
|
+ final QueenAttackCalculator calculator
|
|
|
112
|
+ = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(1, 1));
|
|
|
113
|
+
|
|
104
|
114
|
assertTrue(calculator.canQueensAttackOneAnother());
|
|
105
|
115
|
}
|
|
106
|
116
|
|
|
107
|
117
|
@Ignore
|
|
108
|
118
|
@Test
|
|
109
|
119
|
public void testQueensCanAttackOnFourthDiagonal() {
|
|
110
|
|
- final QueenAttackCalculator calculator = new QueenAttackCalculator(new int[]{2, 2}, new int[]{5, 5});
|
|
|
120
|
+ final QueenAttackCalculator calculator
|
|
|
121
|
+ = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(5, 5));
|
|
|
122
|
+
|
|
111
|
123
|
assertTrue(calculator.canQueensAttackOneAnother());
|
|
112
|
124
|
}
|
|
113
|
125
|
|