use of com.annimon.stream.function.IntPredicate in project Lightweight-Stream-API by aNNiMON.
the class IterateTest method testStreamIterateWithPredicate.
@Test
public void testStreamIterateWithPredicate() {
IntPredicate condition = new IntPredicate() {
@Override
public boolean test(int value) {
return value < 20;
}
};
IntUnaryOperator increment = new IntUnaryOperator() {
@Override
public int applyAsInt(int t) {
return t + 5;
}
};
IntStream.iterate(0, condition, increment).custom(assertElements(arrayContaining(0, 5, 10, 15)));
}
use of com.annimon.stream.function.IntPredicate in project Lightweight-Stream-API by aNNiMON.
the class AllMatchTest method testAllMatch.
@Test
public void testAllMatch() {
IntStream.empty().allMatch(new IntPredicate() {
@Override
public boolean test(int value) {
throw new IllegalStateException();
}
});
assertTrue(IntStream.of(42).allMatch(new IntPredicate() {
@Override
public boolean test(int value) {
return value == 42;
}
}));
assertFalse(IntStream.of(5, 7, 9, 10, 7, 5).allMatch(IntPredicate.Util.negate(Functions.remainderInt(2))));
assertTrue(IntStream.of(5, 7, 9, 11, 7, 5).allMatch(IntPredicate.Util.negate(Functions.remainderInt(2))));
}
Aggregations