use of java8.util.OptionalDouble in project streamsupport by stefan-zobel.
the class FindAnyOpTest method exerciseDoubleStream.
void exerciseDoubleStream(TestData.OfDouble data, Function<DoubleStream, DoubleStream> fs) {
OptionalDouble or = withData(data).terminal(fs, s -> s.findAny()).equalator(DOUBLE_VALID_ANSWER).exercise();
if (or.isPresent()) {
double r = or.getAsDouble();
PrimitiveIterator.OfDouble it = fs.apply(data.stream()).iterator();
boolean contained = false;
while (!contained && it.hasNext()) {
contained = r == it.nextDouble();
}
assertTrue(contained);
} else {
assertFalse(fs.apply(data.stream()).iterator().hasNext());
}
}
Aggregations