diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java index bd92c3355f5..50f263460be 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; @@ -84,6 +85,7 @@ public void testToChar_Character() { assertEquals('B', CharUtils.toChar(CHARACTER_B)); try { CharUtils.toChar((Character) null); + fail("An IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) {} } @@ -100,9 +102,11 @@ public void testToChar_String() { assertEquals('B', CharUtils.toChar("BA")); try { CharUtils.toChar((String) null); + fail("An IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) {} try { CharUtils.toChar(""); + fail("An IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) {} } @@ -128,6 +132,7 @@ public void testToIntValue_char() { assertEquals(9, CharUtils.toIntValue('9')); try { CharUtils.toIntValue('a'); + fail("An IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) {} } @@ -144,9 +149,11 @@ public void testToIntValue_Character() { assertEquals(3, CharUtils.toIntValue(new Character('3'))); try { CharUtils.toIntValue(null); + fail("An IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) {} try { CharUtils.toIntValue(CHARACTER_A); + fail("An IllegalArgumentException should have been thrown"); } catch (final IllegalArgumentException ex) {} } @@ -219,12 +226,8 @@ public void testIsAscii_char() { assertTrue(CharUtils.isAscii('\n')); assertFalse(CharUtils.isAscii(CHAR_COPY)); - for (int i = 0; i < 128; i++) { - if (i < 128) { - assertTrue(CharUtils.isAscii((char) i)); - } else { - assertFalse(CharUtils.isAscii((char) i)); - } + for (int i = 0; i < 255; i++) { + assertEquals(i < 128, CharUtils.isAscii((char) i)); } }