1 /* 2 * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.openjdk.tests.java.util.stream; 24 25 import org.testng.annotations.Test; 26 27 import org.openjdk.testlib.java.util.stream.DoubleStreamTestDataProvider; 28 import org.openjdk.testlib.java.util.stream.IntStreamTestDataProvider; 29 import org.openjdk.testlib.java.util.stream.LongStreamTestDataProvider; 30 import org.openjdk.testlib.java.util.stream.SpliteratorTestHelper; 31 import org.openjdk.testlib.java.util.stream.StreamTestDataProvider; 32 import org.openjdk.testlib.java.util.stream.SpliteratorTestHelper; 33 34 import java.util.function.Supplier; 35 import java.util.Spliterator; 36 37 38 import static org.testng.Assert.*; 39 import static org.testng.Assert.assertEquals; 40 41 /** 42 * SpliteratorTest 43 * 44 * @author Brian Goetz 45 */ 46 @Test 47 public class SpliteratorTest { 48 49 @Test(dataProvider = "Spliterator<Integer>", dataProviderClass = StreamTestDataProvider.class ) testSpliterator(String name, Supplier<Spliterator<Integer>> supplier)50 public void testSpliterator(String name, Supplier<Spliterator<Integer>> supplier) { 51 SpliteratorTestHelper.testSpliterator(supplier); 52 } 53 54 @Test(dataProvider = "IntSpliterator", dataProviderClass = IntStreamTestDataProvider.class ) testIntSpliterator(String name, Supplier<Spliterator.OfInt> supplier)55 public void testIntSpliterator(String name, Supplier<Spliterator.OfInt> supplier) { 56 SpliteratorTestHelper.testIntSpliterator(supplier); 57 } 58 59 @Test(dataProvider = "LongSpliterator", dataProviderClass = LongStreamTestDataProvider.class ) testLongSpliterator(String name, Supplier<Spliterator.OfLong> supplier)60 public void testLongSpliterator(String name, Supplier<Spliterator.OfLong> supplier) { 61 SpliteratorTestHelper.testLongSpliterator(supplier); 62 } 63 64 @Test(dataProvider = "DoubleSpliterator", dataProviderClass = DoubleStreamTestDataProvider.class ) testDoubleSpliterator(String name, Supplier<Spliterator.OfDouble> supplier)65 public void testDoubleSpliterator(String name, Supplier<Spliterator.OfDouble> supplier) { 66 SpliteratorTestHelper.testDoubleSpliterator(supplier); 67 } 68 69 // Android-removed: Project Panama is not available. 70 /* 71 @Test(dataProvider = "SegmentSpliterator", dataProviderClass = SegmentTestDataProvider.class ) 72 public void testSegmentSpliterator(String name, SequenceLayout layout, SpliteratorTestHelper.ContentAsserter<MemorySegment> contentAsserter) { 73 try (ResourceScope scope = ResourceScope.newConfinedScope()) { 74 MemorySegment segment = MemorySegment.allocateNative(layout, scope); 75 SegmentTestDataProvider.initSegment(segment); 76 SpliteratorTestHelper.testSpliterator(() -> segment.spliterator(layout), 77 SegmentTestDataProvider::segmentCopier, contentAsserter); 78 } 79 } 80 */ 81 } 82