Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/test/java/org/apache/commons/lang3/CharUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {}
}

Expand All @@ -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) {}
}

Expand All @@ -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) {}
}

Expand All @@ -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) {}
}

Expand Down Expand Up @@ -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));
}
}

Expand Down