BAEL-2365: added 2 further examples with substring and indexOf

This commit is contained in:
cror 2018-11-11 16:18:36 +01:00
parent 8d9f995624
commit 129aa9ddc9
1 changed files with 10 additions and 0 deletions

View File

@ -59,4 +59,14 @@ public class SubstringUnitTest {
Assert.assertEquals("United States of America", text.substring(text.indexOf('(') + 1, text.indexOf(')')));
}
@Test
public void givenAString_whenUsedSubstringWithLastIndexOf_ShouldReturnProperSubstring() {
Assert.assertEquals("1984", text.substring(text.lastIndexOf('-') + 1, text.indexOf('.')));
}
@Test
public void givenAString_whenUsedSubstringWithIndexOfAString_ShouldReturnProperSubstring() {
Assert.assertEquals("USA (United States of America)", text.substring(text.indexOf("USA"), text.indexOf(')') + 1));
}
}