assertEquals("value", buffer.substringTrimmed(6, buffer.length()));
assertEquals("", buffer.substringTrimmed(13, buffer.length()));
}
public void testSubstringIndexOfOutBound() {
CharArrayBuffer buffer = new CharArrayBuffer(16);
buffer.append("stuff");
try {
buffer.substring(-2, 10);
fail("IndexOutOfBoundsException should have been thrown");
} catch (IndexOutOfBoundsException ex) {
// expected
}
try {
buffer.substringTrimmed(-2, 10);
fail("IndexOutOfBoundsException should have been thrown");
} catch (IndexOutOfBoundsException ex) {
// expected
}
try {
buffer.substring(12, 10);
fail("IndexOutOfBoundsException should have been thrown");
} catch (IndexOutOfBoundsException ex) {
// expected
}
try {
buffer.substringTrimmed(12, 10);
fail("IndexOutOfBoundsException should have been thrown");
} catch (IndexOutOfBoundsException ex) {
// expected
}
try {
buffer.substring(2, 1);
fail("IndexOutOfBoundsException should have been thrown");
} catch (IndexOutOfBoundsException ex) {
// expected
}
try {
buffer.substringTrimmed(2, 1);
fail("IndexOutOfBoundsException should have been thrown");
} catch (IndexOutOfBoundsException ex) {
// expected
}
}