Просмотр исходного кода

Reorder queen-attack tests

Fixes issue #241.
Colin Mullikin 9 лет назад
Родитель
Сommit
c531aee7af
1 измененных файлов: 58 добавлений и 58 удалений
  1. 58
    58
      exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java

+ 58
- 58
exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java Просмотреть файл

@@ -8,127 +8,127 @@ import static org.junit.Assert.assertTrue;
8 8
 
9 9
 public final class QueenAttackCalculatorTest {
10 10
 
11
-    /*
12
-     * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
13
-     * ExpectedExceptions in particular.
14
-     */
15
-    @Rule
16
-    public ExpectedException expectedException = ExpectedException.none();
17
-
18 11
     @Test
19
-    public void testCoordinateWithNegativeRankNotAllowed() {
20
-        expectedException.expect(IllegalArgumentException.class);
21
-        expectedException.expectMessage("Coordinate must have positive rank.");
12
+    public void testQueensThatDoNotShareRankFileOrDiagonalCannotAttack() {
13
+        final QueenAttackCalculator calculator
14
+                = new QueenAttackCalculator(new BoardCoordinate(2, 4), new BoardCoordinate(6, 6));
22 15
 
23
-        new BoardCoordinate(-2, 2);
16
+        assertFalse(calculator.canQueensAttackOneAnother());
24 17
     }
25 18
 
26 19
     @Ignore
27 20
     @Test
28
-    public void testCoordinateWithRankGreaterThan7NotAllowed() {
29
-        expectedException.expect(IllegalArgumentException.class);
30
-        expectedException.expectMessage("Coordinate must have rank <= 7.");
21
+    public void testQueensCanAttackOnTheSameRank() {
22
+        final QueenAttackCalculator calculator
23
+                = new QueenAttackCalculator(new BoardCoordinate(2, 4), new BoardCoordinate(2, 6));
31 24
 
32
-        new BoardCoordinate(8, 4);
25
+        assertTrue(calculator.canQueensAttackOneAnother());
33 26
     }
34 27
 
35 28
     @Ignore
36 29
     @Test
37
-    public void testCoordinateWithNegativeFileNotAllowed() {
38
-        expectedException.expect(IllegalArgumentException.class);
39
-        expectedException.expectMessage("Coordinate must have positive file.");
30
+    public void testQueensCanAttackOnTheSameFile() {
31
+        final QueenAttackCalculator calculator
32
+                = new QueenAttackCalculator(new BoardCoordinate(4, 5), new BoardCoordinate(2, 5));
40 33
 
41
-        new BoardCoordinate(2, -2);
34
+        assertTrue(calculator.canQueensAttackOneAnother());
42 35
     }
43 36
 
44 37
     @Ignore
45 38
     @Test
46
-    public void testCoordinateWithFileGreaterThan7NotAllowed() {
47
-        expectedException.expect(IllegalArgumentException.class);
48
-        expectedException.expectMessage("Coordinate must have file <= 7.");
39
+    public void testQueensCanAttackOnFirstDiagonal() {
40
+        final QueenAttackCalculator calculator
41
+                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(0, 4));
49 42
 
50
-        new BoardCoordinate(4, 8);
43
+        assertTrue(calculator.canQueensAttackOneAnother());
51 44
     }
52 45
 
53 46
     @Ignore
54 47
     @Test
55
-    public void testNullCoordinateNotAllowed() {
56
-        expectedException.expect(IllegalArgumentException.class);
57
-        expectedException.expectMessage("You must supply valid board coordinates for both Queens.");
48
+    public void testQueensCanAttackOnSecondDiagonal() {
49
+        final QueenAttackCalculator calculator
50
+                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(3, 1));
58 51
 
59
-        new QueenAttackCalculator(null, new BoardCoordinate(0, 7));
52
+        assertTrue(calculator.canQueensAttackOneAnother());
60 53
     }
61 54
 
62 55
     @Ignore
63 56
     @Test
64
-    public void testQueensMustNotOccupyTheSameSquare() {
65
-        expectedException.expect(IllegalArgumentException.class);
66
-        expectedException.expectMessage("Queens may not occupy the same board coordinate.");
57
+    public void testQueensCanAttackOnThirdDiagonal() {
58
+        final QueenAttackCalculator calculator
59
+                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(1, 1));
67 60
 
68
-        new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(2, 2));
61
+        assertTrue(calculator.canQueensAttackOneAnother());
69 62
     }
70 63
 
71 64
     @Ignore
72 65
     @Test
73
-    public void testQueensThatDoNotShareRankFileOrDiagonalCannotAttack() {
66
+    public void testQueensCanAttackOnFourthDiagonal() {
74 67
         final QueenAttackCalculator calculator
75
-                = new QueenAttackCalculator(new BoardCoordinate(2, 4), new BoardCoordinate(6, 6));
68
+                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(5, 5));
76 69
 
77
-        assertFalse(calculator.canQueensAttackOneAnother());
70
+        assertTrue(calculator.canQueensAttackOneAnother());
78 71
     }
79 72
 
73
+    /*
74
+     * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
75
+     * ExpectedExceptions in particular.
76
+     */
77
+    @Rule
78
+    public ExpectedException expectedException = ExpectedException.none();
79
+
80 80
     @Ignore
81 81
     @Test
82
-    public void testQueensCanAttackOnTheSameRank() {
83
-        final QueenAttackCalculator calculator
84
-                = new QueenAttackCalculator(new BoardCoordinate(2, 4), new BoardCoordinate(2, 6));
82
+    public void testCoordinateWithNegativeRankNotAllowed() {
83
+        expectedException.expect(IllegalArgumentException.class);
84
+        expectedException.expectMessage("Coordinate must have positive rank.");
85 85
 
86
-        assertTrue(calculator.canQueensAttackOneAnother());
86
+        new BoardCoordinate(-2, 2);
87 87
     }
88 88
 
89 89
     @Ignore
90 90
     @Test
91
-    public void testQueensCanAttackOnTheSameFile() {
92
-        final QueenAttackCalculator calculator
93
-                = new QueenAttackCalculator(new BoardCoordinate(4, 5), new BoardCoordinate(2, 5));
91
+    public void testCoordinateWithRankGreaterThan7NotAllowed() {
92
+        expectedException.expect(IllegalArgumentException.class);
93
+        expectedException.expectMessage("Coordinate must have rank <= 7.");
94 94
 
95
-        assertTrue(calculator.canQueensAttackOneAnother());
95
+        new BoardCoordinate(8, 4);
96 96
     }
97 97
 
98 98
     @Ignore
99 99
     @Test
100
-    public void testQueensCanAttackOnFirstDiagonal() {
101
-        final QueenAttackCalculator calculator
102
-                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(0, 4));
100
+    public void testCoordinateWithNegativeFileNotAllowed() {
101
+        expectedException.expect(IllegalArgumentException.class);
102
+        expectedException.expectMessage("Coordinate must have positive file.");
103 103
 
104
-        assertTrue(calculator.canQueensAttackOneAnother());
104
+        new BoardCoordinate(2, -2);
105 105
     }
106 106
 
107 107
     @Ignore
108 108
     @Test
109
-    public void testQueensCanAttackOnSecondDiagonal() {
110
-        final QueenAttackCalculator calculator
111
-                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(3, 1));
109
+    public void testCoordinateWithFileGreaterThan7NotAllowed() {
110
+        expectedException.expect(IllegalArgumentException.class);
111
+        expectedException.expectMessage("Coordinate must have file <= 7.");
112 112
 
113
-        assertTrue(calculator.canQueensAttackOneAnother());
113
+        new BoardCoordinate(4, 8);
114 114
     }
115 115
 
116 116
     @Ignore
117 117
     @Test
118
-    public void testQueensCanAttackOnThirdDiagonal() {
119
-        final QueenAttackCalculator calculator
120
-                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(1, 1));
118
+    public void testNullCoordinateNotAllowed() {
119
+        expectedException.expect(IllegalArgumentException.class);
120
+        expectedException.expectMessage("You must supply valid board coordinates for both Queens.");
121 121
 
122
-        assertTrue(calculator.canQueensAttackOneAnother());
122
+        new QueenAttackCalculator(null, new BoardCoordinate(0, 7));
123 123
     }
124 124
 
125 125
     @Ignore
126 126
     @Test
127
-    public void testQueensCanAttackOnFourthDiagonal() {
128
-        final QueenAttackCalculator calculator
129
-                = new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(5, 5));
127
+    public void testQueensMustNotOccupyTheSameSquare() {
128
+        expectedException.expect(IllegalArgumentException.class);
129
+        expectedException.expectMessage("Queens may not occupy the same board coordinate.");
130 130
 
131
-        assertTrue(calculator.canQueensAttackOneAnother());
131
+        new QueenAttackCalculator(new BoardCoordinate(2, 2), new BoardCoordinate(2, 2));
132 132
     }
133 133
 
134 134
 }