Search in sources :

Example 1 with CheckResult

use of io.vavr.test.CheckResult in project tutorials by eugenp.

the class PropertyBasedLongRunningUnitTest method givenArbitrarySeq_whenCheckThatEverySecondElementIsEqualToString_thenTestPass.

@Test
public void givenArbitrarySeq_whenCheckThatEverySecondElementIsEqualToString_thenTestPass() {
    // given
    Arbitrary<Integer> multiplesOf2 = Arbitrary.integer().filter(i -> i > 0).filter(i -> i % 2 == 0 && i % 5 != 0);
    // when
    CheckedFunction1<Integer, Boolean> mustEquals = i -> stringsSupplier().get(i).equals("DividedByTwoWithoutRemainder");
    // then
    CheckResult result = Property.def("Every second element must equal to DividedByTwoWithoutRemainder").forAll(multiplesOf2).suchThat(mustEquals).check(10_000, 100);
    result.assertIsSatisfied();
}
Also used : Match(io.vavr.API.Match) CheckResult(io.vavr.test.CheckResult) Predicate(java.util.function.Predicate) Arbitrary(io.vavr.test.Arbitrary) Property(io.vavr.test.Property) Stream(io.vavr.collection.Stream) Test(org.junit.Test) Case(io.vavr.API.Case) CheckedFunction1(io.vavr.CheckedFunction1) API.$(io.vavr.API.$) CheckResult(io.vavr.test.CheckResult) Test(org.junit.Test)

Aggregations

API.$ (io.vavr.API.$)1 Case (io.vavr.API.Case)1 Match (io.vavr.API.Match)1 CheckedFunction1 (io.vavr.CheckedFunction1)1 Stream (io.vavr.collection.Stream)1 Arbitrary (io.vavr.test.Arbitrary)1 CheckResult (io.vavr.test.CheckResult)1 Property (io.vavr.test.Property)1 Predicate (java.util.function.Predicate)1 Test (org.junit.Test)1