|
|
@@ -150,10 +150,18 @@ public class BaseConverterTest {
|
|
150
|
150
|
@Ignore("Remove to run test")
|
|
151
|
151
|
@Test
|
|
152
|
152
|
public void testEmptyDigits() {
|
|
153
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
154
|
|
- expectedException.expectMessage("You must supply at least one digit.");
|
|
|
153
|
+ final BaseConverter baseConverter = new BaseConverter(2, new int[]{});
|
|
|
154
|
+
|
|
|
155
|
+ final int[] expectedDigits = new int[]{0};
|
|
|
156
|
+ final int[] actualDigits = baseConverter.convertToBase(10);
|
|
155
|
157
|
|
|
156
|
|
- new BaseConverter(2, new int[]{});
|
|
|
158
|
+ assertArrayEquals(
|
|
|
159
|
+ String.format(
|
|
|
160
|
+ "Expected digits: %s but found digits: %s",
|
|
|
161
|
+ Arrays.toString(expectedDigits),
|
|
|
162
|
+ Arrays.toString(actualDigits)),
|
|
|
163
|
+ expectedDigits,
|
|
|
164
|
+ actualDigits);
|
|
157
|
165
|
}
|
|
158
|
166
|
|
|
159
|
167
|
@Ignore("Remove to run test")
|
|
|
@@ -176,19 +184,35 @@ public class BaseConverterTest {
|
|
176
|
184
|
@Ignore("Remove to run test")
|
|
177
|
185
|
@Test
|
|
178
|
186
|
public void testMultipleZeros() {
|
|
179
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
180
|
|
- expectedException.expectMessage("Digits may not contain leading zeros.");
|
|
|
187
|
+ final BaseConverter baseConverter = new BaseConverter(10, new int[]{0, 0, 0});
|
|
|
188
|
+
|
|
|
189
|
+ final int[] expectedDigits = new int[]{0};
|
|
|
190
|
+ final int[] actualDigits = baseConverter.convertToBase(2);
|
|
181
|
191
|
|
|
182
|
|
- new BaseConverter(10, new int[]{0, 0, 0});
|
|
|
192
|
+ assertArrayEquals(
|
|
|
193
|
+ String.format(
|
|
|
194
|
+ "Expected digits: %s but found digits: %s",
|
|
|
195
|
+ Arrays.toString(expectedDigits),
|
|
|
196
|
+ Arrays.toString(actualDigits)),
|
|
|
197
|
+ expectedDigits,
|
|
|
198
|
+ actualDigits);
|
|
183
|
199
|
}
|
|
184
|
200
|
|
|
185
|
201
|
@Ignore("Remove to run test")
|
|
186
|
202
|
@Test
|
|
187
|
203
|
public void testLeadingZeros() {
|
|
188
|
|
- expectedException.expect(IllegalArgumentException.class);
|
|
189
|
|
- expectedException.expectMessage("Digits may not contain leading zeros.");
|
|
|
204
|
+ final BaseConverter baseConverter = new BaseConverter(7, new int[]{0, 6, 0});
|
|
|
205
|
+
|
|
|
206
|
+ final int[] expectedDigits = new int[]{4, 2};
|
|
|
207
|
+ final int[] actualDigits = baseConverter.convertToBase(10);
|
|
190
|
208
|
|
|
191
|
|
- new BaseConverter(7, new int[]{0, 6, 0});
|
|
|
209
|
+ assertArrayEquals(
|
|
|
210
|
+ String.format(
|
|
|
211
|
+ "Expected digits: %s but found digits: %s",
|
|
|
212
|
+ Arrays.toString(expectedDigits),
|
|
|
213
|
+ Arrays.toString(actualDigits)),
|
|
|
214
|
+ expectedDigits,
|
|
|
215
|
+ actualDigits);
|
|
192
|
216
|
}
|
|
193
|
217
|
|
|
194
|
218
|
@Ignore("Remove to run test")
|
|
|
@@ -250,7 +274,7 @@ public class BaseConverterTest {
|
|
250
|
274
|
@Ignore("Remove to run test")
|
|
251
|
275
|
@Test
|
|
252
|
276
|
public void testSecondBaseIsZero() {
|
|
253
|
|
- final BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
|
|
|
277
|
+ final BaseConverter baseConverter = new BaseConverter(10, new int[]{7});
|
|
254
|
278
|
|
|
255
|
279
|
expectedException.expect(IllegalArgumentException.class);
|
|
256
|
280
|
expectedException.expectMessage("Bases must be at least 2.");
|