|
|
@@ -1,7 +1,5 @@
|
|
1
|
1
|
import org.junit.Ignore;
|
|
2
|
|
-import org.junit.Rule;
|
|
3
|
2
|
import org.junit.Test;
|
|
4
|
|
-import org.junit.rules.ExpectedException;
|
|
5
|
3
|
|
|
6
|
4
|
import java.util.Arrays;
|
|
7
|
5
|
import java.util.Collections;
|
|
|
@@ -9,34 +7,28 @@ import java.util.List;
|
|
9
|
7
|
|
|
10
|
8
|
import static org.junit.Assert.assertEquals;
|
|
11
|
9
|
|
|
|
10
|
+/*
|
|
|
11
|
+ * version: 1.0.0
|
|
|
12
|
+ */
|
|
12
|
13
|
public class MinesweeperBoardTest {
|
|
13
|
14
|
|
|
14
|
|
- /*
|
|
15
|
|
- * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
|
|
16
|
|
- * ExpectedExceptions in particular.
|
|
17
|
|
- */
|
|
18
|
|
- @Rule
|
|
19
|
|
- public ExpectedException expectedException = ExpectedException.none();
|
|
20
|
|
-
|
|
21
|
15
|
@Test
|
|
22
|
16
|
public void testInputBoardWithNoRowsAndNoColumns() {
|
|
23
|
17
|
final List<String> inputBoard = Collections.emptyList();
|
|
24
|
|
- final List<String> expectedAnnotatedRepresentation = Collections.emptyList();
|
|
25
|
|
- final List<String> actualAnnotatedRepresentation
|
|
26
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
18
|
+ final List<String> expectedNumberedBoard = Collections.emptyList();
|
|
|
19
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
27
|
20
|
|
|
28
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
21
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
29
|
22
|
}
|
|
30
|
23
|
|
|
31
|
24
|
@Ignore("Remove to run test")
|
|
32
|
25
|
@Test
|
|
33
|
26
|
public void testInputBoardWithOneRowAndNoColumns() {
|
|
34
|
27
|
final List<String> inputBoard = Collections.singletonList("");
|
|
35
|
|
- final List<String> expectedAnnotatedRepresentation = Collections.singletonList("");
|
|
36
|
|
- final List<String> actualAnnotatedRepresentation
|
|
37
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
28
|
+ final List<String> expectedNumberedBoard = Collections.singletonList("");
|
|
|
29
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
38
|
30
|
|
|
39
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
31
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
40
|
32
|
}
|
|
41
|
33
|
|
|
42
|
34
|
@Ignore("Remove to run test")
|
|
|
@@ -48,16 +40,15 @@ public class MinesweeperBoardTest {
|
|
48
|
40
|
" "
|
|
49
|
41
|
);
|
|
50
|
42
|
|
|
51
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
43
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
52
|
44
|
" ",
|
|
53
|
45
|
" ",
|
|
54
|
46
|
" "
|
|
55
|
47
|
);
|
|
56
|
48
|
|
|
57
|
|
- final List<String> actualAnnotatedRepresentation
|
|
58
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
49
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
59
|
50
|
|
|
60
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
51
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
61
|
52
|
}
|
|
62
|
53
|
|
|
63
|
54
|
@Ignore("Remove to run test")
|
|
|
@@ -69,16 +60,15 @@ public class MinesweeperBoardTest {
|
|
69
|
60
|
"***"
|
|
70
|
61
|
);
|
|
71
|
62
|
|
|
72
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
63
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
73
|
64
|
"***",
|
|
74
|
65
|
"***",
|
|
75
|
66
|
"***"
|
|
76
|
67
|
);
|
|
77
|
68
|
|
|
78
|
|
- final List<String> actualAnnotatedRepresentation
|
|
79
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
69
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
80
|
70
|
|
|
81
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
71
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
82
|
72
|
}
|
|
83
|
73
|
|
|
84
|
74
|
@Ignore("Remove to run test")
|
|
|
@@ -90,16 +80,15 @@ public class MinesweeperBoardTest {
|
|
90
|
80
|
" "
|
|
91
|
81
|
);
|
|
92
|
82
|
|
|
93
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
83
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
94
|
84
|
"111",
|
|
95
|
85
|
"1*1",
|
|
96
|
86
|
"111"
|
|
97
|
87
|
);
|
|
98
|
88
|
|
|
99
|
|
- final List<String> actualAnnotatedRepresentation
|
|
100
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
89
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
101
|
90
|
|
|
102
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
91
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
103
|
92
|
}
|
|
104
|
93
|
|
|
105
|
94
|
@Ignore("Remove to run test")
|
|
|
@@ -111,16 +100,15 @@ public class MinesweeperBoardTest {
|
|
111
|
100
|
"***"
|
|
112
|
101
|
);
|
|
113
|
102
|
|
|
114
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
103
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
115
|
104
|
"***",
|
|
116
|
105
|
"*8*",
|
|
117
|
106
|
"***"
|
|
118
|
107
|
);
|
|
119
|
108
|
|
|
120
|
|
- final List<String> actualAnnotatedRepresentation
|
|
121
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
109
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
122
|
110
|
|
|
123
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
111
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
124
|
112
|
}
|
|
125
|
113
|
|
|
126
|
114
|
@Ignore("Remove to run test")
|
|
|
@@ -130,14 +118,13 @@ public class MinesweeperBoardTest {
|
|
130
|
118
|
" * * "
|
|
131
|
119
|
);
|
|
132
|
120
|
|
|
133
|
|
- final List<String> expectedAnnotatedRepresentation = Collections.singletonList(
|
|
|
121
|
+ final List<String> expectedNumberedBoard = Collections.singletonList(
|
|
134
|
122
|
"1*2*1"
|
|
135
|
123
|
);
|
|
136
|
124
|
|
|
137
|
|
- final List<String> actualAnnotatedRepresentation
|
|
138
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
125
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
139
|
126
|
|
|
140
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
127
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
141
|
128
|
}
|
|
142
|
129
|
|
|
143
|
130
|
@Ignore("Remove to run test")
|
|
|
@@ -147,14 +134,13 @@ public class MinesweeperBoardTest {
|
|
147
|
134
|
"* *"
|
|
148
|
135
|
);
|
|
149
|
136
|
|
|
150
|
|
- final List<String> expectedAnnotatedRepresentation = Collections.singletonList(
|
|
|
137
|
+ final List<String> expectedNumberedBoard = Collections.singletonList(
|
|
151
|
138
|
"*1 1*"
|
|
152
|
139
|
);
|
|
153
|
140
|
|
|
154
|
|
- final List<String> actualAnnotatedRepresentation
|
|
155
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
141
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
156
|
142
|
|
|
157
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
143
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
158
|
144
|
}
|
|
159
|
145
|
|
|
160
|
146
|
@Ignore("Remove to run test")
|
|
|
@@ -168,7 +154,7 @@ public class MinesweeperBoardTest {
|
|
168
|
154
|
" "
|
|
169
|
155
|
);
|
|
170
|
156
|
|
|
171
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
157
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
172
|
158
|
"1",
|
|
173
|
159
|
"*",
|
|
174
|
160
|
"2",
|
|
|
@@ -176,10 +162,9 @@ public class MinesweeperBoardTest {
|
|
176
|
162
|
"1"
|
|
177
|
163
|
);
|
|
178
|
164
|
|
|
179
|
|
- final List<String> actualAnnotatedRepresentation
|
|
180
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
165
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
181
|
166
|
|
|
182
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
167
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
183
|
168
|
}
|
|
184
|
169
|
|
|
185
|
170
|
@Ignore("Remove to run test")
|
|
|
@@ -193,7 +178,7 @@ public class MinesweeperBoardTest {
|
|
193
|
178
|
"*"
|
|
194
|
179
|
);
|
|
195
|
180
|
|
|
196
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
181
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
197
|
182
|
"*",
|
|
198
|
183
|
"1",
|
|
199
|
184
|
" ",
|
|
|
@@ -201,10 +186,9 @@ public class MinesweeperBoardTest {
|
|
201
|
186
|
"*"
|
|
202
|
187
|
);
|
|
203
|
188
|
|
|
204
|
|
- final List<String> actualAnnotatedRepresentation
|
|
205
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
189
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
206
|
190
|
|
|
207
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
191
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
208
|
192
|
}
|
|
209
|
193
|
|
|
210
|
194
|
@Ignore("Remove to run test")
|
|
|
@@ -218,7 +202,7 @@ public class MinesweeperBoardTest {
|
|
218
|
202
|
" * "
|
|
219
|
203
|
);
|
|
220
|
204
|
|
|
221
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
205
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
222
|
206
|
" 2*2 ",
|
|
223
|
207
|
"25*52",
|
|
224
|
208
|
"*****",
|
|
|
@@ -226,10 +210,9 @@ public class MinesweeperBoardTest {
|
|
226
|
210
|
" 2*2 "
|
|
227
|
211
|
);
|
|
228
|
212
|
|
|
229
|
|
- final List<String> actualAnnotatedRepresentation
|
|
230
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
|
213
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
231
|
214
|
|
|
232
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
|
215
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
233
|
216
|
}
|
|
234
|
217
|
|
|
235
|
218
|
@Ignore("Remove to run test")
|
|
|
@@ -244,7 +227,7 @@ public class MinesweeperBoardTest {
|
|
244
|
227
|
" "
|
|
245
|
228
|
);
|
|
246
|
229
|
|
|
247
|
|
- final List<String> expectedAnnotatedRepresentation = Arrays.asList(
|
|
|
230
|
+ final List<String> expectedNumberedBoard = Arrays.asList(
|
|
248
|
231
|
"1*22*1",
|
|
249
|
232
|
"12*322",
|
|
250
|
233
|
" 123*2",
|
|
|
@@ -253,43 +236,9 @@ public class MinesweeperBoardTest {
|
|
253
|
236
|
"111111"
|
|
254
|
237
|
);
|
|
255
|
238
|
|
|
256
|
|
- final List<String> actualAnnotatedRepresentation
|
|
257
|
|
- = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation();
|
|
258
|
|
-
|
|
259
|
|
- assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation);
|
|
260
|
|
- }
|
|
261
|
|
-
|
|
262
|
|
- @Ignore("Remove to run test")
|
|
263
|
|
- @Test
|
|
264
|
|
- public void testNullInputBoardIsRejected() {
|
|
265
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
266
|
|
- expectedException.expectMessage("Input board may not be null.");
|
|
267
|
|
-
|
|
268
|
|
- new MinesweeperBoard(null);
|
|
269
|
|
- }
|
|
|
239
|
+ final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers();
|
|
270
|
240
|
|
|
271
|
|
- @Ignore("Remove to run test")
|
|
272
|
|
- @Test
|
|
273
|
|
- public void testInputBoardWithInvalidSymbolsIsRejected() {
|
|
274
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
275
|
|
- expectedException.expectMessage("Input board can only contain the characters ' ' and '*'.");
|
|
276
|
|
-
|
|
277
|
|
- new MinesweeperBoard(Collections.singletonList(" * & "));
|
|
278
|
|
- }
|
|
279
|
|
-
|
|
280
|
|
- @Ignore("Remove to run test")
|
|
281
|
|
- @Test
|
|
282
|
|
- public void testInputBoardWithInconsistentRowLengthsIsRejected() {
|
|
283
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
284
|
|
- expectedException.expectMessage("Input board rows must all have the same number of columns.");
|
|
285
|
|
-
|
|
286
|
|
- new MinesweeperBoard(Arrays.asList(
|
|
287
|
|
- "*",
|
|
288
|
|
- "**",
|
|
289
|
|
- "* *",
|
|
290
|
|
- "* *",
|
|
291
|
|
- "* *"
|
|
292
|
|
- ));
|
|
|
241
|
+ assertEquals(expectedNumberedBoard, actualNumberedBoard);
|
|
293
|
242
|
}
|
|
294
|
243
|
|
|
295
|
244
|
}
|