@@ -150,10 +150,18 @@ public void test15BitInteger() {
150150 @ Ignore ("Remove to run test" )
151151 @ Test
152152 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 );
155157
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 );
157165 }
158166
159167 @ Ignore ("Remove to run test" )
@@ -176,19 +184,35 @@ public void testSingleZero() {
176184 @ Ignore ("Remove to run test" )
177185 @ Test
178186 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 );
181191
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 );
183199 }
184200
185201 @ Ignore ("Remove to run test" )
186202 @ Test
187203 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 );
190208
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 );
192216 }
193217
194218 @ Ignore ("Remove to run test" )
@@ -250,7 +274,7 @@ public void testSecondBaseIsOne() {
250274 @ Ignore ("Remove to run test" )
251275 @ Test
252276 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 });
254278
255279 expectedException .expect (IllegalArgumentException .class );
256280 expectedException .expectMessage ("Bases must be at least 2." );
0 commit comments