|
|
@@ -7,6 +7,9 @@ import java.util.Arrays;
|
|
7
|
7
|
|
|
8
|
8
|
import static org.junit.Assert.assertArrayEquals;
|
|
9
|
9
|
|
|
|
10
|
+/*
|
|
|
11
|
+ * version: 1.1.0
|
|
|
12
|
+ */
|
|
10
|
13
|
public class BaseConverterTest {
|
|
11
|
14
|
|
|
12
|
15
|
/*
|
|
|
@@ -197,69 +200,69 @@ public class BaseConverterTest {
|
|
197
|
200
|
|
|
198
|
201
|
@Ignore("Remove to run test")
|
|
199
|
202
|
@Test
|
|
200
|
|
- public void testNegativeDigit() {
|
|
|
203
|
+ public void testFirstBaseIsOne() {
|
|
201
|
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
|
210
|
@Ignore("Remove to run test")
|
|
208
|
211
|
@Test
|
|
209
|
|
- public void testInvalidPositiveDigit() {
|
|
|
212
|
+ public void testFirstBaseIsZero() {
|
|
210
|
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
|
219
|
@Ignore("Remove to run test")
|
|
217
|
220
|
@Test
|
|
218
|
|
- public void testFirstBaseIsOne() {
|
|
|
221
|
+ public void testFirstBaseIsNegative() {
|
|
219
|
222
|
expectedException.expect(IllegalArgumentException.class);
|
|
220
|
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
|
228
|
@Ignore("Remove to run test")
|
|
226
|
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
|
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
|
237
|
@Ignore("Remove to run test")
|
|
237
|
238
|
@Test
|
|
238
|
|
- public void testFirstBaseIsZero() {
|
|
|
239
|
+ public void testInvalidPositiveDigit() {
|
|
239
|
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
|
246
|
@Ignore("Remove to run test")
|
|
246
|
247
|
@Test
|
|
247
|
|
- public void testSecondBaseIsZero() {
|
|
|
248
|
+ public void testSecondBaseIsOne() {
|
|
248
|
249
|
final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
|
|
249
|
250
|
|
|
250
|
251
|
expectedException.expect(IllegalArgumentException.class);
|
|
251
|
252
|
expectedException.expectMessage("Bases must be at least 2.");
|
|
252
|
253
|
|
|
253
|
|
- baseConverter.convertToBase(0);
|
|
|
254
|
+ baseConverter.convertToBase(1);
|
|
254
|
255
|
}
|
|
255
|
256
|
|
|
256
|
257
|
@Ignore("Remove to run test")
|
|
257
|
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
|
262
|
expectedException.expect(IllegalArgumentException.class);
|
|
260
|
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
|
268
|
@Ignore("Remove to run test")
|