Added support for contains function

This commit is contained in:
Shekhar Gulati
2016-05-04 20:06:17 +05:30
parent 49e51fe52b
commit 313fb3f989
3 changed files with 73 additions and 11 deletions
+25 -1
View File
@@ -7,7 +7,7 @@ import java.util.Optional;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.collection.IsArrayContainingInOrder.arrayContaining;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.*;
import static strman.Strman.*;
public class StrmanTest {
@@ -81,4 +81,28 @@ public class StrmanTest {
String input = " foo bar bazz hello world ";
assertThat(collapseWhitespace(input), equalTo("foo bar bazz hello world"));
}
@Test
public void containsWithCaseSensitiveFalse_shouldReturnTrueWhenStringContainsNeedle() throws Exception {
String[] fixture = {
"foo bar",
"bar foo",
"foobar",
"foo"
};
Arrays.stream(fixture).forEach(el -> assertTrue(contains(el, "FOO")));
}
@Test
public void containsWithCaseSensitiveTrue_shouldReturnTrueWhenStringContainsNeedle() throws Exception {
String[] fixture = {
"foo bar",
"bar foo",
"foobar",
"foo"
};
Arrays.stream(fixture).forEach(el -> assertFalse(contains(el, "FOO", true)));
}
}