Added support for endsWith and its variants

This commit is contained in:
Shekhar Gulati
2016-05-09 15:10:20 +05:30
parent 4198488b06
commit 217ebf9361
2 changed files with 83 additions and 3 deletions
+36
View File
@@ -194,4 +194,40 @@ public class StrmanTest {
assertThat(countSubstr("aaa", "aa", true, true), equalTo(2L));
}
@Test
public void endsWith_caseSensitive_ShouldBeTrueWhenStringEndsWithSearchStr() throws Exception {
String[] fixture = {
"foo bar",
"bar"
};
Arrays.stream(fixture).forEach(el -> assertTrue(endsWith(el, "bar")));
}
@Test
public void endsWith_notCaseSensitive_ShouldBeTrueWhenStringEndsWithSearchStr() throws Exception {
String[] fixture = {
"foo bar",
"bar"
};
Arrays.stream(fixture).forEach(el -> assertTrue(endsWith(el, "BAR", false)));
}
@Test
public void endsWith_caseSensitiveAtPosition_ShouldBeTrueWhenStringEndsWithSearchStr() throws Exception {
String[] fixture = {
"foo barr",
"barr"
};
Arrays.stream(fixture).forEach(el -> assertTrue(endsWith(el, "bar", el.length() - 1, true)));
}
@Test
public void endsWith_notCaseSensitiveAtPosition_ShouldBeTrueWhenStringEndsWithSearchStr() throws Exception {
String[] fixture = {
"foo barr",
"barr"
};
Arrays.stream(fixture).forEach(el -> assertTrue(endsWith(el, "BAR", el.length() - 1, false)));
}
}