use of java8.util.OptionalLong in project streamsupport by stefan-zobel.
the class FindAnyOpTest method exerciseLongStream.
void exerciseLongStream(TestData.OfLong data, Function<LongStream, LongStream> fs) {
OptionalLong or = withData(data).terminal(fs, s -> s.findAny()).equalator(LONG_VALID_ANSWER).exercise();
if (or.isPresent()) {
long r = or.getAsLong();
PrimitiveIterator.OfLong it = fs.apply(data.stream()).iterator();
boolean contained = false;
while (!contained && it.hasNext()) {
contained = r == it.nextLong();
}
assertTrue(contained);
} else {
assertFalse(fs.apply(data.stream()).iterator().hasNext());
}
}
Aggregations