Merge pull request #5661 from cror/substring-indexof

BAEL-2365: added 2 further examples with substring and indexOf
This commit is contained in:
Eric Martin 2018-11-12 21:17:29 -06:00 committed by GitHub
commit 06bb9653b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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));
}
}