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

all-your-base: update to v1.1.0 of tests

I chose to skip the x-common test case "both bases are negative" since
the xjava implementation of this exercise forces the first base to be
validated before a second base can be supplied. This test would
therefore be redundant since we already have tests that validate the
first base.
Stuart Kent 9 лет назад
Родитель
Сommit
9bb1c3b49a
1 измененных файлов: 23 добавлений и 20 удалений
  1. 23
    20
      exercises/all-your-base/src/test/java/BaseConverterTest.java

+ 23
- 20
exercises/all-your-base/src/test/java/BaseConverterTest.java Просмотреть файл

7
 
7
 
8
 import static org.junit.Assert.assertArrayEquals;
8
 import static org.junit.Assert.assertArrayEquals;
9
 
9
 
10
+/*
11
+ * version: 1.1.0
12
+ */
10
 public class BaseConverterTest {
13
 public class BaseConverterTest {
11
 
14
 
12
     /*
15
     /*
197
 
200
 
198
     @Ignore("Remove to run test")
201
     @Ignore("Remove to run test")
199
     @Test
202
     @Test
200
-    public void testNegativeDigit() {
203
+    public void testFirstBaseIsOne() {
201
         expectedException.expect(IllegalArgumentException.class);
204
         expectedException.expect(IllegalArgumentException.class);
202
-        expectedException.expectMessage("Digits may not be negative.");
205
+        expectedException.expectMessage("Bases must be at least 2.");
203
 
206
 
204
-        new BaseConverter(2, new int[]{1, -1, 1, 0, 1, 0});
207
+        new BaseConverter(1, new int[]{});
205
     }
208
     }
206
 
209
 
207
     @Ignore("Remove to run test")
210
     @Ignore("Remove to run test")
208
     @Test
211
     @Test
209
-    public void testInvalidPositiveDigit() {
212
+    public void testFirstBaseIsZero() {
210
         expectedException.expect(IllegalArgumentException.class);
213
         expectedException.expect(IllegalArgumentException.class);
211
-        expectedException.expectMessage("All digits must be strictly less than the base.");
214
+        expectedException.expectMessage("Bases must be at least 2.");
212
 
215
 
213
-        new BaseConverter(2, new int[]{1, 2, 1, 0, 1, 0});
216
+        new BaseConverter(0, new int[]{});
214
     }
217
     }
215
 
218
 
216
     @Ignore("Remove to run test")
219
     @Ignore("Remove to run test")
217
     @Test
220
     @Test
218
-    public void testFirstBaseIsOne() {
221
+    public void testFirstBaseIsNegative() {
219
         expectedException.expect(IllegalArgumentException.class);
222
         expectedException.expect(IllegalArgumentException.class);
220
         expectedException.expectMessage("Bases must be at least 2.");
223
         expectedException.expectMessage("Bases must be at least 2.");
221
 
224
 
222
-        new BaseConverter(1, new int[]{});
225
+        new BaseConverter(-2, new int[]{});
223
     }
226
     }
224
 
227
 
225
     @Ignore("Remove to run test")
228
     @Ignore("Remove to run test")
226
     @Test
229
     @Test
227
-    public void testSecondBaseIsOne() {
228
-        final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
229
-
230
+    public void testNegativeDigit() {
230
         expectedException.expect(IllegalArgumentException.class);
231
         expectedException.expect(IllegalArgumentException.class);
231
-        expectedException.expectMessage("Bases must be at least 2.");
232
+        expectedException.expectMessage("Digits may not be negative.");
232
 
233
 
233
-        baseConverter.convertToBase(1);
234
+        new BaseConverter(2, new int[]{1, -1, 1, 0, 1, 0});
234
     }
235
     }
235
 
236
 
236
     @Ignore("Remove to run test")
237
     @Ignore("Remove to run test")
237
     @Test
238
     @Test
238
-    public void testFirstBaseIsZero() {
239
+    public void testInvalidPositiveDigit() {
239
         expectedException.expect(IllegalArgumentException.class);
240
         expectedException.expect(IllegalArgumentException.class);
240
-        expectedException.expectMessage("Bases must be at least 2.");
241
+        expectedException.expectMessage("All digits must be strictly less than the base.");
241
 
242
 
242
-        new BaseConverter(0, new int[]{});
243
+        new BaseConverter(2, new int[]{1, 2, 1, 0, 1, 0});
243
     }
244
     }
244
 
245
 
245
     @Ignore("Remove to run test")
246
     @Ignore("Remove to run test")
246
     @Test
247
     @Test
247
-    public void testSecondBaseIsZero() {
248
+    public void testSecondBaseIsOne() {
248
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
249
         final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
249
 
250
 
250
         expectedException.expect(IllegalArgumentException.class);
251
         expectedException.expect(IllegalArgumentException.class);
251
         expectedException.expectMessage("Bases must be at least 2.");
252
         expectedException.expectMessage("Bases must be at least 2.");
252
 
253
 
253
-        baseConverter.convertToBase(0);
254
+        baseConverter.convertToBase(1);
254
     }
255
     }
255
 
256
 
256
     @Ignore("Remove to run test")
257
     @Ignore("Remove to run test")
257
     @Test
258
     @Test
258
-    public void testFirstBaseIsNegative() {
259
+    public void testSecondBaseIsZero() {
260
+        final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
261
+
259
         expectedException.expect(IllegalArgumentException.class);
262
         expectedException.expect(IllegalArgumentException.class);
260
         expectedException.expectMessage("Bases must be at least 2.");
263
         expectedException.expectMessage("Bases must be at least 2.");
261
 
264
 
262
-        new BaseConverter(-2, new int[]{});
265
+        baseConverter.convertToBase(0);
263
     }
266
     }
264
 
267
 
265
     @Ignore("Remove to run test")
268
     @Ignore("Remove to run test")