Java Code Examples for java.util.stream.TestData#OfInt
The following examples show how to use
java.util.stream.TestData#OfInt .
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: StreamBuilderTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void testIntSingleton() { TestData.OfInt data = TestData.Factory.ofIntSupplier("[0, 1)", () -> IntStream.of(1)); withData(data). stream(s -> s). expectedResult(Collections.singletonList(1)). exercise(); withData(data). stream(s -> s.map(i -> i)). expectedResult(Collections.singletonList(1)). exercise(); }
Example 2
Source File: InfiniteStreamWithLimitOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStream.limit") public void testIntUnorderedIteration(String description, UnaryOperator<IntStream> fs) { // Source is a right-balanced tree of infinite size TestData.OfInt iterator = TestData.Factory.ofIntSupplier( "[1, 2, 3, ...]", () -> IntStream.iterate(1, i -> i + 1)); // Ref withData(iterator). stream(s -> fs.apply(s.unordered())). resultAsserter(unorderedAsserter()). exercise(); }
Example 3
Source File: InfiniteStreamWithLimitOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStream.limit") public void testIntUnorderedGenerator(String description, UnaryOperator<IntStream> fs) { // Source is spliterator of infinite size TestData.OfInt generator = TestData.Factory.ofIntSupplier( "[1, 1, ...]", () -> IntStream.generate(() -> 1)); withData(generator). stream(s -> fs.apply(s.filter(i -> true).unordered())). exercise(); }
Example 4
Source File: IntReduceTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testOps(String name, TestData.OfInt data) { assertEquals(0, (int) exerciseTerminalOps(data, s -> s.filter(ipFalse), s -> s.reduce(0, irPlus))); OptionalInt seedless = exerciseTerminalOps(data, s -> s.reduce(irPlus)); int folded = exerciseTerminalOps(data, s -> s.reduce(0, irPlus)); assertEquals(folded, seedless.orElse(0)); seedless = exerciseTerminalOps(data, s -> s.reduce(irMin)); folded = exerciseTerminalOps(data, s -> s.reduce(Integer.MAX_VALUE, irMin)); assertEquals(folded, seedless.orElse(Integer.MAX_VALUE)); seedless = exerciseTerminalOps(data, s -> s.reduce(irMax)); folded = exerciseTerminalOps(data, s -> s.reduce(Integer.MIN_VALUE, irMax)); assertEquals(folded, seedless.orElse(Integer.MIN_VALUE)); seedless = exerciseTerminalOps(data, s -> s.map(irDoubler), s -> s.reduce(irPlus)); folded = exerciseTerminalOps(data, s -> s.map(irDoubler), s -> s.reduce(0, irPlus)); assertEquals(folded, seedless.orElse(0)); seedless = exerciseTerminalOps(data, s -> s.map(irDoubler), s -> s.reduce(irMin)); folded = exerciseTerminalOps(data, s -> s.map(irDoubler), s -> s.reduce(Integer.MAX_VALUE, irMin)); assertEquals(folded, seedless.orElse(Integer.MAX_VALUE)); seedless = exerciseTerminalOps(data, s -> s.map(irDoubler), s -> s.reduce(irMax)); folded = exerciseTerminalOps(data, s -> s.map(irDoubler), s -> s.reduce(Integer.MIN_VALUE, irMax)); assertEquals(folded, seedless.orElse(Integer.MIN_VALUE)); }
Example 5
Source File: StreamBuilderTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testIntSingleton() { TestData.OfInt data = TestData.Factory.ofIntSupplier("[0, 1)", () -> IntStream.of(1)); withData(data). stream(s -> s). expectedResult(Collections.singletonList(1)). exercise(); withData(data). stream(s -> s.map(i -> i)). expectedResult(Collections.singletonList(1)). exercise(); }
Example 6
Source File: SplittableRandomTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "ints") public void testInts(TestData.OfInt data, ResultAsserter<Iterable<Integer>> ra) { withData(data). stream(s -> s). without(IntStreamTestScenario.CLEAR_SIZED_SCENARIOS). resultAsserter(ra). exercise(); }
Example 7
Source File: CountTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testOps(String name, TestData.OfInt data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(IntStream::count). expectedResult(expectedCount.get()). exercise(); }
Example 8
Source File: InfiniteStreamWithLimitOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStream.limit") public void testIntUnorderedGenerator(String description, UnaryOperator<IntStream> fs) { // Source is spliterator of infinite size TestData.OfInt generator = TestData.Factory.ofIntSupplier( "[1, 1, ...]", () -> IntStream.generate(() -> 1)); withData(generator). stream(s -> fs.apply(s.filter(i -> true).unordered())). exercise(); }
Example 9
Source File: MatchOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testIntStream(String name, TestData.OfInt data) { for (IntPredicate p : INT_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, intKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(ipFalse), intKinds.get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(ipEven), intKinds.get(kind).apply(p)); } } }
Example 10
Source File: CountTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testOps(String name, TestData.OfInt data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(IntStream::count). expectedResult(expectedCount.get()). exercise(); }
Example 11
Source File: StreamBuilderTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void testIntStreamBuilder(int size, Function<Integer, IntStream> supplier) { TestData.OfInt data = TestData.Factory.ofIntSupplier(String.format("[0, %d)", size), () -> supplier.apply(size)); withData(data). stream(s -> s). expectedResult(IntStream.range(0, size).toArray()). exercise(); withData(data). stream(s -> s.map(i -> i)). expectedResult(IntStream.range(0, size).toArray()). exercise(); }
Example 12
Source File: SplittableRandomTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "ints") public void testInts(TestData.OfInt data, ResultAsserter<Iterable<Integer>> ra) { withData(data). stream(s -> s). without(IntStreamTestScenario.CLEAR_SIZED_SCENARIOS). resultAsserter(ra). exercise(); }
Example 13
Source File: RangeTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
TestData.OfInt intRangeClosedData(int start, int end) { return TestData.Factory.ofIntSupplier("int rangeClosed", () -> IntStream.rangeClosed(start, end)); }
Example 14
Source File: InfiniteStreamWithLimitOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private TestData.OfInt intRange(int l, int u) { return TestData.Factory.ofIntSupplier( String.format("[%d, %d)", l, u), () -> IntStream.range(l, u)); }
Example 15
Source File: RangeTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
TestData.OfInt intRangeClosedData(int start, int end) { return TestData.Factory.ofIntSupplier("int rangeClosed", () -> IntStream.rangeClosed(start, end)); }
Example 16
Source File: StreamSpliteratorTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testIntSpliterators(String name, TestData.OfInt data) { for (Function<IntStream, IntStream> f : intStreamFunctions()) { SpliteratorTestHelper.testIntSpliterator(() -> f.apply(data.stream()).spliterator()); } }
Example 17
Source File: StreamSpliteratorTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testIntSpliterators(String name, TestData.OfInt data) { for (Function<IntStream, IntStream> f : intStreamFunctions()) { SpliteratorTestHelper.testIntSpliterator(() -> f.apply(data.stream()).spliterator()); } }
Example 18
Source File: RangeTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
TestData.OfInt intRangeData(int start, int end) { return TestData.Factory.ofIntSupplier("int range", () -> IntStream.range(start, end)); }
Example 19
Source File: InfiniteStreamWithLimitOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private TestData.OfInt intRange(int l, int u) { return TestData.Factory.ofIntSupplier( String.format("[%d, %d)", l, u), () -> IntStream.range(l, u)); }
Example 20
Source File: StreamSpliteratorTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class) public void testIntParSpliterators(String name, TestData.OfInt data) { for (Function<IntStream, IntStream> f : intStreamFunctions()) { SpliteratorTestHelper.testIntSpliterator(() -> f.apply(data.parallelStream()).spliterator()); } }