Package net.emaze.dysfunctional.strings.predicates

Source Code of net.emaze.dysfunctional.strings.predicates.StringContainsTest

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"));
    }
}
TOP

Related Classes of net.emaze.dysfunctional.strings.predicates.StringContainsTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.