use of java.util.function.DoublePredicate in project assertj-core by joel-costigliola.
the class DoublePredicateAssert_rejects_Test method should_pass_when_predicate_does_not_accept_value.
@Test
public void should_pass_when_predicate_does_not_accept_value() {
DoublePredicate predicate = val -> val <= 2;
assertThat(predicate).rejects(3.0);
}
use of java.util.function.DoublePredicate in project assertj-core by joel-costigliola.
the class DoublePredicateAssert_rejects_Test method should_fail_when_predicate_accepts_some_value.
@Test
public void should_fail_when_predicate_accepts_some_value() {
DoublePredicate predicate = num -> num <= 2;
double[] matchValues = new double[] { 1.0, 2.0, 3.0 };
List<Double> matchValuesList = DoubleStream.of(matchValues).boxed().collect(Collectors.toList());
thrown.expectAssertionError(noElementsShouldMatch(matchValuesList, 1D, PredicateDescription.GIVEN).create());
assertThat(predicate).rejects(matchValues);
}
use of java.util.function.DoublePredicate in project assertj-core by joel-costigliola.
the class DoublePredicateAssert_rejects_Test method should_fail_when_predicate_accepts_value.
@Test
public void should_fail_when_predicate_accepts_value() {
DoublePredicate predicate = val -> val <= 2;
Predicate<Double> wrapPredicate = predicate::test;
double expectedValue = 2.0;
thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
assertThat(predicate).rejects(expectedValue);
}
use of java.util.function.DoublePredicate in project assertj-core by joel-costigliola.
the class DoublePredicateAssert_accepts_Test method should_fail_when_predicate_does_not_accept_all_values.
@Test
public void should_fail_when_predicate_does_not_accept_all_values() {
DoublePredicate predicate = val -> val <= 2;
double[] matchValues = new double[] { 1.0, 2.0, 3.0 };
thrown.expectAssertionError(elementsShouldMatch(matchValues, 3D, PredicateDescription.GIVEN).create());
assertThat(predicate).accepts(matchValues);
}
use of java.util.function.DoublePredicate in project j2objc by google.
the class DoublePredicateTest method testNegate.
public void testNegate() throws Exception {
double arg = 5.0d;
DoublePredicate alwaysTrue = x -> {
assertEquals(x, arg);
return true;
};
assertFalse(alwaysTrue.negate().test(arg));
DoublePredicate alwaysFalse = x -> {
assertEquals(x, arg);
return false;
};
assertTrue(alwaysFalse.negate().test(arg));
}
Aggregations