package net.emaze.dysfunctional.strings.predicates;
import net.emaze.dysfunctional.dispatching.logic.Predicate;
import org.junit.Assert;
import org.junit.Test;
/**
*
* @author rferranti
*/
public class StringContainsTest {
@Test(expected = IllegalArgumentException.class)
public void creatingWithNullNeedleYieldsException() {
new StringContains(null);
}
@Test(expected = IllegalArgumentException.class)
public void testingWithNullHaystackYieldsException() {
new StringContains("a").accept(null);
}
@Test(expected = ClassCastException.class)
public void passingNonStringToErasureYieldsException() {
Predicate p = new StringContains("a");
p.accept(new Object());
}
@Test
public void testingContainedNeedleYieldsTrue() {
Assert.assertTrue(new StringContains("a").accept("a"));
}
@Test
public void testingNotContainedNeedleYieldsFalse() {
Assert.assertFalse(new StringContains("a").accept("A"));
}
}