use of java.util.function.IntPredicate in project gatk by broadinstitute.
the class MathUtilsUnitTest method testAllMatchInt.
@Test
public void testAllMatchInt() {
for (final double[] doubleArray : testArrays) {
final int[] array = Arrays.stream(doubleArray).mapToInt(x -> (int) Math.round(x)).toArray();
final IntPredicate pred = x -> x > -1;
Assert.assertEquals(MathUtils.allMatch(array, pred), Arrays.stream(array).allMatch(pred));
}
}
use of java.util.function.IntPredicate in project j2objc by google.
the class IntPredicateTest method testAnd.
public void testAnd() throws Exception {
int arg = 5;
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 };
IntPredicate alwaysTrue = x -> {
alwaysTrueInvoked.set(true);
assertEquals(x, arg);
return true;
};
IntPredicate alwaysTrue2 = x -> {
alwaysTrue2Invoked.set(true);
assertEquals(x, arg);
return true;
};
IntPredicate alwaysFalse = x -> {
alwaysFalseInvoked.set(true);
assertEquals(x, arg);
return false;
};
IntPredicate 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.IntPredicate in project j2objc by google.
the class IntPredicateTest method testAnd_null.
public void testAnd_null() throws Exception {
IntPredicate alwaysTrue = x -> true;
try {
alwaysTrue.and(null);
fail();
} catch (NullPointerException expected) {
}
}
use of java.util.function.IntPredicate in project j2objc by google.
the class IntPredicateTest method testNegate.
public void testNegate() throws Exception {
int arg = 5;
IntPredicate alwaysTrue = x -> {
assertEquals(x, arg);
return true;
};
assertFalse(alwaysTrue.negate().test(arg));
IntPredicate alwaysFalse = x -> {
assertEquals(x, arg);
return false;
};
assertTrue(alwaysFalse.negate().test(arg));
}
use of java.util.function.IntPredicate in project j2objc by google.
the class IntPredicateTest method testOr_null.
public void testOr_null() throws Exception {
IntPredicate alwaysTrue = x -> true;
try {
alwaysTrue.or(null);
fail();
} catch (NullPointerException expected) {
}
}
Aggregations