Java Code Examples for java.util.stream.TestData#OfLong
The following examples show how to use
java.util.stream.TestData#OfLong .
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: CountTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testOps(String name, TestData.OfLong data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(LongStream::count). expectedResult(expectedCount.get()). exercise(); }
Example 2
Source File: InfiniteStreamWithLimitOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStream.limit") public void testLongUnorderedIteration(String description, UnaryOperator<LongStream> fs) { // Source is a right-balanced tree of infinite size TestData.OfLong iterator = TestData.Factory.ofLongSupplier( "[1L, 2L, 3L, ...]", () -> LongStream.iterate(1, i -> i + 1)); // Ref withData(iterator). stream(s -> fs.apply(s.unordered())). resultAsserter(unorderedAsserter()). exercise(); }
Example 3
Source File: StreamBuilderTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void testLongStreamBuilder(int size, Function<Integer, LongStream> supplier) { TestData.OfLong data = TestData.Factory.ofLongSupplier(String.format("[0, %d)", size), () -> supplier.apply(size)); withData(data). stream(s -> s). expectedResult(LongStream.range(0, size).toArray()). exercise(); withData(data). stream(s -> s.map(i -> i)). expectedResult(LongStream.range(0, size).toArray()). exercise(); }
Example 4
Source File: MatchOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testLongStream(String name, TestData.OfLong data) { for (LongPredicate p : LONG_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, longKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(lpFalse), longKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(lpEven), longKinds.get(kind).apply(p)); } } }
Example 5
Source File: CountTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testOps(String name, TestData.OfLong data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(LongStream::count). expectedResult(expectedCount.get()). exercise(); }
Example 6
Source File: StreamBuilderTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void testLongStreamBuilder(int size, Function<Integer, LongStream> supplier) { TestData.OfLong data = TestData.Factory.ofLongSupplier(String.format("[0, %d)", size), () -> supplier.apply(size)); withData(data). stream(s -> s). expectedResult(LongStream.range(0, size).toArray()). exercise(); withData(data). stream(s -> s.map(i -> i)). expectedResult(LongStream.range(0, size).toArray()). exercise(); }
Example 7
Source File: StreamBuilderTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testLongSingleton() { TestData.OfLong data = TestData.Factory.ofLongSupplier("[0, 1)", () -> LongStream.of(1)); withData(data). stream(s -> s). expectedResult(Collections.singletonList(1L)). exercise(); withData(data). stream(s -> s.map(i -> i)). expectedResult(Collections.singletonList(1L)). exercise(); }
Example 8
Source File: InfiniteStreamWithLimitOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStream.limit") public void testLongUnorderedIteration(String description, UnaryOperator<LongStream> fs) { // Source is a right-balanced tree of infinite size TestData.OfLong iterator = TestData.Factory.ofLongSupplier( "[1L, 2L, 3L, ...]", () -> LongStream.iterate(1, i -> i + 1)); // Ref withData(iterator). stream(s -> fs.apply(s.unordered())). resultAsserter(unorderedAsserter()). exercise(); }
Example 9
Source File: InfiniteStreamWithLimitOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStream.limit") public void testLongUnorderedGenerator(String description, UnaryOperator<LongStream> fs) { // Source is spliterator of infinite size TestData.OfLong generator = TestData.Factory.ofLongSupplier( "[1L, 1L, ...]", () -> LongStream.generate(() -> 1)); withData(generator). stream(s -> fs.apply(s.filter(i -> true).unordered())). exercise(); }
Example 10
Source File: MatchOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testLongStream(String name, TestData.OfLong data) { for (LongPredicate p : LONG_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, longKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(lpFalse), longKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(lpEven), longKinds.get(kind).apply(p)); } } }
Example 11
Source File: RangeTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
TestData.OfLong longRangeData(long start, long end) { return TestData.Factory.ofLongSupplier("long range", () -> LongStream.range(start, end)); }
Example 12
Source File: RangeTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
TestData.OfLong longRangeClosedData(long start, long end) { return TestData.Factory.ofLongSupplier("long rangeClosed", () -> LongStream.rangeClosed(start, end)); }
Example 13
Source File: StreamSpliteratorTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testLongSpliterators(String name, TestData.OfLong data) { for (Function<LongStream, LongStream> f : longStreamFunctions()) { SpliteratorTestHelper.testLongSpliterator(() -> f.apply(data.stream()).spliterator()); } }
Example 14
Source File: StreamSpliteratorTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testLongParSpliterators(String name, TestData.OfLong data) { for (Function<LongStream, LongStream> f : longStreamFunctions()) { SpliteratorTestHelper.testLongSpliterator(() -> f.apply(data.parallelStream()).spliterator()); } }
Example 15
Source File: RangeTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
TestData.OfLong longRangeClosedData(long start, long end) { return TestData.Factory.ofLongSupplier("long rangeClosed", () -> LongStream.rangeClosed(start, end)); }
Example 16
Source File: InfiniteStreamWithLimitOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private TestData.OfLong proxiedLongRange(long l, long u) { return TestData.Factory.ofLongSupplier( String.format("[%d, %d)", l, u), () -> StreamSupport.longStream(proxyNotSubsized(LongStream.range(l, u).spliterator()), false)); }
Example 17
Source File: InfiniteStreamWithLimitOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private TestData.OfLong longs() { return longRange(0, Long.MAX_VALUE); }
Example 18
Source File: InfiniteStreamWithLimitOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private TestData.OfLong longRange(long l, long u) { return TestData.Factory.ofLongSupplier( String.format("[%d, %d)", l, u), () -> LongStream.range(l, u)); }
Example 19
Source File: InfiniteStreamWithLimitOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private TestData.OfLong longRange(long l, long u) { return TestData.Factory.ofLongSupplier( String.format("[%d, %d)", l, u), () -> LongStream.range(l, u)); }
Example 20
Source File: StreamSpliteratorTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class) public void testLongParSpliterators(String name, TestData.OfLong data) { for (Function<LongStream, LongStream> f : longStreamFunctions()) { SpliteratorTestHelper.testLongSpliterator(() -> f.apply(data.parallelStream()).spliterator()); } }