Java Code Examples for java.util.stream.TestData#OfDouble

The following examples show how to use java.util.stream.TestData#OfDouble . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SplittableRandomTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "doubles")
public void testDoubles(TestData.OfDouble data, ResultAsserter<Iterable<Double>> ra) {
    withData(data).
            stream(s -> s).
            without(DoubleStreamTestScenario.CLEAR_SIZED_SCENARIOS).
            resultAsserter(ra).
            exercise();
}
 
Example 2
Source File: CountTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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();
}
 
Example 3
Source File: InfiniteStreamWithLimitOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "DoubleStream.limit")
public void testDoubleUnorderedGenerator(String description, UnaryOperator<DoubleStream> fs) {
    // Source is spliterator of infinite size
    TestData.OfDouble generator = TestData.Factory.ofDoubleSupplier(
            "[1.0, 1.0, ...]", () -> DoubleStream.generate(() -> 1.0));

    withData(generator).
            stream(s -> fs.apply(s.filter(i -> true).unordered())).
            exercise();
}
 
Example 4
Source File: InfiniteStreamWithLimitOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "DoubleStream.limit")
public void testDoubleUnorderedIteration(String description, UnaryOperator<DoubleStream> fs) {
    // Source is a right-balanced tree of infinite size
    TestData.OfDouble iterator = TestData.Factory.ofDoubleSupplier(
            "[1.0, 2.0, 3.0, ...]", () -> DoubleStream.iterate(1, i -> i + 1));

    // Ref
    withData(iterator).
            stream(s -> fs.apply(s.unordered())).
            resultAsserter(unorderedAsserter()).
            exercise();
}
 
Example 5
Source File: StreamBuilderTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testDoubleSingleton() {
    TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("[0, 1)", () -> DoubleStream.of(1));

    withData(data).
            stream(s -> s).
            expectedResult(Collections.singletonList(1.0)).
            exercise();

    withData(data).
            stream(s -> s.map(i -> i)).
            expectedResult(Collections.singletonList(1.0)).
            exercise();
}
 
Example 6
Source File: StreamBuilderTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void testDoubleStreamBuilder(int size, Function<Integer, DoubleStream> supplier) {
    TestData.OfDouble data = TestData.Factory.ofDoubleSupplier(String.format("[0, %d)", size),
                                                               () -> supplier.apply(size));

    withData(data).
            stream(s -> s).
            expectedResult(IntStream.range(0, size).asDoubleStream().toArray()).
            exercise();

    withData(data).
            stream(s -> s.map(i -> i)).
            expectedResult(IntStream.range(0, size).asDoubleStream().toArray()).
            exercise();
}
 
Example 7
Source File: StreamBuilderTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void testDoubleStreamBuilder(int size, Function<Integer, DoubleStream> supplier) {
    TestData.OfDouble data = TestData.Factory.ofDoubleSupplier(String.format("[0, %d)", size),
                                                               () -> supplier.apply(size));

    withData(data).
            stream(s -> s).
            expectedResult(IntStream.range(0, size).asDoubleStream().toArray()).
            exercise();

    withData(data).
            stream(s -> s.map(i -> i)).
            expectedResult(IntStream.range(0, size).asDoubleStream().toArray()).
            exercise();
}
 
Example 8
Source File: StreamBuilderTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testDoubleSingleton() {
    TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("[0, 1)", () -> DoubleStream.of(1));

    withData(data).
            stream(s -> s).
            expectedResult(Collections.singletonList(1.0)).
            exercise();

    withData(data).
            stream(s -> s.map(i -> i)).
            expectedResult(Collections.singletonList(1.0)).
            exercise();
}
 
Example 9
Source File: InfiniteStreamWithLimitOpTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "DoubleStream.limit")
public void testDoubleUnorderedIteration(String description, UnaryOperator<DoubleStream> fs) {
    // Source is a right-balanced tree of infinite size
    TestData.OfDouble iterator = TestData.Factory.ofDoubleSupplier(
            "[1.0, 2.0, 3.0, ...]", () -> DoubleStream.iterate(1, i -> i + 1));

    // Ref
    withData(iterator).
            stream(s -> fs.apply(s.unordered())).
            resultAsserter(unorderedAsserter()).
            exercise();
}
 
Example 10
Source File: SplittableRandomTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "doubles")
public void testDoubles(TestData.OfDouble data, ResultAsserter<Iterable<Double>> ra) {
    withData(data).
            stream(s -> s).
            without(DoubleStreamTestScenario.CLEAR_SIZED_SCENARIOS).
            resultAsserter(ra).
            exercise();
}
 
Example 11
Source File: MatchOpTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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));
        }
    }
}
 
Example 12
Source File: InfiniteStreamWithLimitOpTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "DoubleStream.limit")
public void testDoubleUnorderedGenerator(String description, UnaryOperator<DoubleStream> fs) {
    // Source is spliterator of infinite size
    TestData.OfDouble generator = TestData.Factory.ofDoubleSupplier(
            "[1.0, 1.0, ...]", () -> DoubleStream.generate(() -> 1.0));

    withData(generator).
            stream(s -> fs.apply(s.filter(i -> true).unordered())).
            exercise();
}
 
Example 13
Source File: StreamSpliteratorTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@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());
    }
}
 
Example 14
Source File: InfiniteStreamWithLimitOpTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private TestData.OfDouble doubleRange(long l, long u) {
    return TestData.Factory.ofDoubleSupplier(
            String.format("[%d, %d)", l, u),
            () -> LongStream.range(l, u).mapToDouble(i -> (double) i));
}
 
Example 15
Source File: InfiniteStreamWithLimitOpTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private TestData.OfDouble doubles() {
    return doubleRange(0, 1L << 53);
}
 
Example 16
Source File: StreamSpliteratorTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@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());
    }
}
 
Example 17
Source File: StreamSpliteratorTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@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());
    }
}
 
Example 18
Source File: StreamSpliteratorTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@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());
    }
}
 
Example 19
Source File: InfiniteStreamWithLimitOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private TestData.OfDouble doubleRange(long l, long u) {
    return TestData.Factory.ofDoubleSupplier(
            String.format("[%d, %d)", l, u),
            () -> LongStream.range(l, u).mapToDouble(i -> (double) i));
}
 
Example 20
Source File: InfiniteStreamWithLimitOpTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private TestData.OfDouble doubles() {
    return doubleRange(0, 1L << 53);
}