public void testCodePointAt_IndexOutOfBoundsException() { try { UnicodeEscaper.codePointAt("Testing...", 4, 2); fail(); } catch (IndexOutOfBoundsException expected) { } }
public void testNullInput() { UnicodeEscaper e = SIMPLE_ESCAPER; try { e.escape((String) null); fail("Null string should cause exception"); } catch (NullPointerException expected) { // Pass } }
public void testTrailingHighSurrogate() { String test = "abc" + Character.MIN_HIGH_SURROGATE; try { escapeAsString(NOP_ESCAPER, test); fail("Trailing high surrogate should cause exception"); } catch (IllegalArgumentException expected) { // Pass } try { escapeAsString(SIMPLE_ESCAPER, test); fail("Trailing high surrogate should cause exception"); } catch (IllegalArgumentException expected) { // Pass } }
public void testBadStrings() { UnicodeEscaper e = SIMPLE_ESCAPER; String[] BAD_STRINGS = { String.valueOf(Character.MIN_LOW_SURROGATE), Character.MIN_LOW_SURROGATE + "xyz", "abc" + Character.MIN_LOW_SURROGATE, "abc" + Character.MIN_LOW_SURROGATE + "xyz", String.valueOf(Character.MAX_LOW_SURROGATE), Character.MAX_LOW_SURROGATE + "xyz", "abc" + Character.MAX_LOW_SURROGATE, "abc" + Character.MAX_LOW_SURROGATE + "xyz", }; for (String s : BAD_STRINGS) { try { escapeAsString(e, s); fail("Isolated low surrogate should cause exception [" + s + "]"); } catch (IllegalArgumentException expected) { // Pass } } }
public void testNullInput() { UnicodeEscaper e = SIMPLE_ESCAPER; try { e.escape((String) null); fail("Null string should cause exception"); } catch (NullPointerException expected) { // Pass } }
public void testCodePointAt_IndexOutOfBoundsException() { try { UnicodeEscaper.codePointAt("Testing...", 4, 2); fail(); } catch (IndexOutOfBoundsException expected) { } }
public void testTrailingHighSurrogate() { String test = "abc" + Character.MIN_HIGH_SURROGATE; try { escapeAsString(NOP_ESCAPER, test); fail("Trailing high surrogate should cause exception"); } catch (IllegalArgumentException expected) { // Pass } try { escapeAsString(SIMPLE_ESCAPER, test); fail("Trailing high surrogate should cause exception"); } catch (IllegalArgumentException expected) { // Pass } }
public void testBadStrings() { UnicodeEscaper e = SIMPLE_ESCAPER; String[] BAD_STRINGS = { String.valueOf(Character.MIN_LOW_SURROGATE), Character.MIN_LOW_SURROGATE + "xyz", "abc" + Character.MIN_LOW_SURROGATE, "abc" + Character.MIN_LOW_SURROGATE + "xyz", String.valueOf(Character.MAX_LOW_SURROGATE), Character.MAX_LOW_SURROGATE + "xyz", "abc" + Character.MAX_LOW_SURROGATE, "abc" + Character.MAX_LOW_SURROGATE + "xyz", }; for (String s : BAD_STRINGS) { try { escapeAsString(e, s); fail("Isolated low surrogate should cause exception [" + s + "]"); } catch (IllegalArgumentException expected) { // Pass } } }