Search in sources :

Example 1 with OptionalDouble

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());
    }
}
Also used : PrimitiveIterator(java8.util.PrimitiveIterator) OptionalDouble(java8.util.OptionalDouble)

Aggregations

OptionalDouble (java8.util.OptionalDouble)1 PrimitiveIterator (java8.util.PrimitiveIterator)1