Split up and simplify tests

This commit is contained in:
Sebb 2015-08-11 11:48:14 +01:00
parent 6849dfc8a6
commit 68acbc803e
1 changed files with 10 additions and 15 deletions

View File

@ -61,21 +61,16 @@ public class CharSequenceUtilsTest {
Assert.assertEquals("12", CharSequenceUtils.subSequence("012", 1)); Assert.assertEquals("12", CharSequenceUtils.subSequence("012", 1));
Assert.assertEquals("2", CharSequenceUtils.subSequence("012", 2)); Assert.assertEquals("2", CharSequenceUtils.subSequence("012", 2));
Assert.assertEquals(StringUtils.EMPTY, CharSequenceUtils.subSequence("012", 3)); Assert.assertEquals(StringUtils.EMPTY, CharSequenceUtils.subSequence("012", 3));
//
// Exception expected
//
try {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, -1));
Assert.fail("Expected " + IndexOutOfBoundsException.class.getName());
} catch (final IndexOutOfBoundsException e) {
// Expected
}
try {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, 1));
Assert.fail("Expected " + IndexOutOfBoundsException.class.getName());
} catch (final IndexOutOfBoundsException e) {
// Expected
}
} }
@Test(expected=IndexOutOfBoundsException.class)
public void testSubSequenceNegativeStart() {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, -1));
}
@Test(expected=IndexOutOfBoundsException.class)
public void testSubSequenceTooLong() {
Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, 1));
}
} }