@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) public void testOps(String name, TestData.OfDouble data) { long expectedCount = data.size(); withData(data). terminal(DoubleStream::count). expectedResult(expectedCount). exercise(); withData(data). terminal(s -> s.filter(e -> true), DoubleStream::count). expectedResult(expectedCount). exercise(); expectedCount = data.into(new HashSet<>()).size(); withData(data). terminal(DoubleStream::distinct, DoubleStream::count). expectedResult(expectedCount). exercise(); withData(data). terminal(s -> s.unordered().distinct(), DoubleStream::count). expectedResult(expectedCount). exercise(); }
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleStream(String name, TestData.OfDouble data) { for (DoublePredicate p : DOUBLE_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, doubleKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(dpFalse), doubleKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(dpEven), doubleKinds.get(kind).apply(p)); } } }
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) public void testOps(String name, TestData.OfDouble data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(DoubleStream::count). expectedResult(expectedCount.get()). exercise(); }
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleOps(String name, TestData.OfDouble data) { Collection<Double> result = exerciseOps(data, s -> s.flatMap(i -> Collections.singleton(i).stream().mapToDouble(j -> j))); assertEquals(data.size(), result.size()); assertContents(data, result); result = exerciseOps(data, s -> DoubleStream.empty()); assertEquals(0, result.size()); }
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleSpliterators(String name, TestData.OfDouble data) { for (Function<DoubleStream, DoubleStream> f : doubleStreamFunctions()) { SpliteratorTestHelper.testDoubleSpliterator(() -> f.apply(data.stream()).spliterator()); } }
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleParSpliterators(String name, TestData.OfDouble data) { for (Function<DoubleStream, DoubleStream> f : doubleStreamFunctions()) { SpliteratorTestHelper.testDoubleSpliterator(() -> f.apply(data.parallelStream()).spliterator()); } }
@Test(dataProvider = "DoubleStreamTestData.small", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleSpliterators(String name, TestData.OfDouble data) { for (Function<DoubleStream, DoubleStream> f : doubleStreamFunctions()) { SpliteratorTestHelper.testDoubleSpliterator(() -> f.apply(data.stream()).spliterator()); } }
@Test(dataProvider = "DoubleStreamTestData.small", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleParSpliterators(String name, TestData.OfDouble data) { for (Function<DoubleStream, DoubleStream> f : doubleStreamFunctions()) { SpliteratorTestHelper.testDoubleSpliterator(() -> f.apply(data.parallelStream()).spliterator()); } }
@Test(dataProvider = "DoubleStreamTestData.small", dataProviderClass = DoubleStreamTestDataProvider.class) public void testDoubleOpsX(String name, TestData.OfDouble data) { exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).asDoubleStream())); exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).asDoubleStream())); }