use of java.util.function.DoublePredicate in project j2objc by google.
the class DoublePredicateTest method testOr.
public void testOr() throws Exception {
double arg = 5.0d;
AtomicBoolean alwaysTrueInvoked = new AtomicBoolean(false);
AtomicBoolean alwaysTrue2Invoked = new AtomicBoolean(false);
AtomicBoolean alwaysFalseInvoked = new AtomicBoolean(false);
AtomicBoolean alwaysFalse2Invoked = new AtomicBoolean(false);
AtomicBoolean[] invocationState = { alwaysTrueInvoked, alwaysTrue2Invoked, alwaysFalseInvoked, alwaysFalse2Invoked };
DoublePredicate alwaysTrue = x -> {
alwaysTrueInvoked.set(true);
assertEquals(x, arg);
return true;
};
DoublePredicate alwaysTrue2 = x -> {
alwaysTrue2Invoked.set(true);
assertEquals(x, arg);
return true;
};
DoublePredicate alwaysFalse = x -> {
alwaysFalseInvoked.set(true);
assertEquals(x, arg);
return false;
};
DoublePredicate alwaysFalse2 = x -> {
alwaysFalse2Invoked.set(true);
assertEquals(x, arg);
return false;
};
// true || true
resetToFalse(invocationState);
assertTrue(alwaysTrue.or(alwaysTrue2).test(arg));
assertTrue(alwaysTrueInvoked.get() && !alwaysTrue2Invoked.get());
// true || false
resetToFalse(invocationState);
assertTrue(alwaysTrue.or(alwaysFalse).test(arg));
assertTrue(alwaysTrueInvoked.get() && !alwaysFalseInvoked.get());
// false || false
resetToFalse(invocationState);
assertFalse(alwaysFalse.or(alwaysFalse2).test(arg));
assertTrue(alwaysFalseInvoked.get() && alwaysFalse2Invoked.get());
// false || true
resetToFalse(invocationState);
assertTrue(alwaysFalse.or(alwaysTrue).test(arg));
assertTrue(alwaysFalseInvoked.get() && alwaysTrueInvoked.get());
}
use of java.util.function.DoublePredicate in project j2objc by google.
the class DoublePredicateTest method testAnd.
public void testAnd() throws Exception {
double arg = 5.0d;
AtomicBoolean alwaysTrueInvoked = new AtomicBoolean(false);
AtomicBoolean alwaysTrue2Invoked = new AtomicBoolean(false);
AtomicBoolean alwaysFalseInvoked = new AtomicBoolean(false);
AtomicBoolean alwaysFalse2Invoked = new AtomicBoolean(false);
AtomicBoolean[] invocationState = { alwaysTrueInvoked, alwaysTrue2Invoked, alwaysFalseInvoked, alwaysFalse2Invoked };
DoublePredicate alwaysTrue = x -> {
alwaysTrueInvoked.set(true);
assertEquals(x, arg);
return true;
};
DoublePredicate alwaysTrue2 = x -> {
alwaysTrue2Invoked.set(true);
assertEquals(x, arg);
return true;
};
DoublePredicate alwaysFalse = x -> {
alwaysFalseInvoked.set(true);
assertEquals(x, arg);
return false;
};
DoublePredicate alwaysFalse2 = x -> {
alwaysFalse2Invoked.set(true);
assertEquals(x, arg);
return false;
};
// true && true
resetToFalse(invocationState);
assertTrue(alwaysTrue.and(alwaysTrue2).test(arg));
assertTrue(alwaysTrueInvoked.get() && alwaysTrue2Invoked.get());
// true && false
resetToFalse(invocationState);
assertFalse(alwaysTrue.and(alwaysFalse).test(arg));
assertTrue(alwaysTrueInvoked.get() && alwaysFalseInvoked.get());
// false && false
resetToFalse(invocationState);
assertFalse(alwaysFalse.and(alwaysFalse2).test(arg));
assertTrue(alwaysFalseInvoked.get() && !alwaysFalse2Invoked.get());
// false && true
resetToFalse(invocationState);
assertFalse(alwaysFalse.and(alwaysTrue).test(arg));
assertTrue(alwaysFalseInvoked.get() && !alwaysTrueInvoked.get());
}
use of java.util.function.DoublePredicate in project j2objc by google.
the class DoublePredicateTest method testAnd_null.
public void testAnd_null() throws Exception {
DoublePredicate alwaysTrue = x -> true;
try {
alwaysTrue.and(null);
fail();
} catch (NullPointerException expected) {
}
}
Aggregations