< prev index next >

test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java

Print this page




 649             if (size == 0) {
 650                 db.addMap(m -> Collections.<Integer, Integer>emptyMap());
 651             }
 652             else if (size == 1) {
 653                 db.addMap(m -> Collections.singletonMap(exp.get(0), exp.get(0)));
 654             }
 655         }
 656 
 657         return spliteratorDataProvider = data.toArray(new Object[0][]);
 658     }
 659 
 660     private static List<Integer> listIntRange(int upTo) {
 661         List<Integer> exp = new ArrayList<>();
 662         for (int i = 0; i < upTo; i++)
 663             exp.add(i);
 664         return Collections.unmodifiableList(exp);
 665     }
 666 
 667     @Test(dataProvider = "Spliterator<Integer>")
 668     public void testNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 669         executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining(null));
 670         executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance(null));
 671     }
 672 
 673     @Test(dataProvider = "Spliterator<Integer>")
 674     public void testForEach(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 675         testForEach(exp, s, UnaryOperator.identity());
 676     }
 677 
 678     @Test(dataProvider = "Spliterator<Integer>")
 679     public void testTryAdvance(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 680         testTryAdvance(exp, s, UnaryOperator.identity());
 681     }
 682 
 683     @Test(dataProvider = "Spliterator<Integer>")
 684     public void testMixedTryAdvanceForEach(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 685         testMixedTryAdvanceForEach(exp, s, UnaryOperator.identity());
 686     }
 687 
 688     @Test(dataProvider = "Spliterator<Integer>")
 689     public void testMixedTraverseAndSplit(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 690         testMixedTraverseAndSplit(exp, s, UnaryOperator.identity());


 849             SpliteratorOfIntCharDataBuilder cdb = new SpliteratorOfIntCharDataBuilder(data, string);
 850             cdb.add("\"%s\"", s -> s);
 851             cdb.add("new CharSequenceImpl(\"%s\")", CharSequenceImpl::new);
 852             cdb.add("new StringBuilder(\"%s\")", StringBuilder::new);
 853             cdb.add("new StringBuffer(\"%s\")", StringBuffer::new);
 854             cdb.add("CharBuffer.wrap(\"%s\".toCharArray())", s -> CharBuffer.wrap(s.toCharArray()));
 855         }
 856 
 857         return spliteratorOfIntDataProvider = data.toArray(new Object[0][]);
 858     }
 859 
 860     private static int[] arrayIntRange(int upTo) {
 861         int[] exp = new int[upTo];
 862         for (int i = 0; i < upTo; i++)
 863             exp[i] = i;
 864         return exp;
 865     }
 866 
 867     @Test(dataProvider = "Spliterator.OfInt")
 868     public void testIntNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 869         executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((IntConsumer) null));
 870         executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((IntConsumer) null));
 871     }
 872 
 873     @Test(dataProvider = "Spliterator.OfInt")
 874     public void testIntForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 875         testForEach(exp, s, intBoxingConsumer());
 876     }
 877 
 878     @Test(dataProvider = "Spliterator.OfInt")
 879     public void testIntTryAdvance(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 880         testTryAdvance(exp, s, intBoxingConsumer());
 881     }
 882 
 883     @Test(dataProvider = "Spliterator.OfInt")
 884     public void testIntMixedTryAdvanceForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 885         testMixedTryAdvanceForEach(exp, s, intBoxingConsumer());
 886     }
 887 
 888     @Test(dataProvider = "Spliterator.OfInt")
 889     public void testIntMixedTraverseAndSplit(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 890         testMixedTraverseAndSplit(exp, s, intBoxingConsumer());


 992 
 993         return spliteratorOfLongDataProvider = data.toArray(new Object[0][]);
 994     }
 995 
 996     private static List<Long> listLongRange(int upTo) {
 997         List<Long> exp = new ArrayList<>();
 998         for (long i = 0; i < upTo; i++)
 999             exp.add(i);
1000         return Collections.unmodifiableList(exp);
1001     }
1002 
1003     private static long[] arrayLongRange(int upTo) {
1004         long[] exp = new long[upTo];
1005         for (int i = 0; i < upTo; i++)
1006             exp[i] = i;
1007         return exp;
1008     }
1009 
1010     @Test(dataProvider = "Spliterator.OfLong")
1011     public void testLongNullPointerException(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1012         executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((LongConsumer) null));
1013         executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((LongConsumer) null));
1014     }
1015 
1016     @Test(dataProvider = "Spliterator.OfLong")
1017     public void testLongForEach(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1018         testForEach(exp, s, longBoxingConsumer());
1019     }
1020 
1021     @Test(dataProvider = "Spliterator.OfLong")
1022     public void testLongTryAdvance(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1023         testTryAdvance(exp, s, longBoxingConsumer());
1024     }
1025 
1026     @Test(dataProvider = "Spliterator.OfLong")
1027     public void testLongMixedTryAdvanceForEach(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1028         testMixedTryAdvanceForEach(exp, s, longBoxingConsumer());
1029     }
1030 
1031     @Test(dataProvider = "Spliterator.OfLong")
1032     public void testLongMixedTraverseAndSplit(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1033         testMixedTraverseAndSplit(exp, s, longBoxingConsumer());


1135 
1136         return spliteratorOfDoubleDataProvider = data.toArray(new Object[0][]);
1137     }
1138 
1139     private static List<Double> listDoubleRange(int upTo) {
1140         List<Double> exp = new ArrayList<>();
1141         for (double i = 0; i < upTo; i++)
1142             exp.add(i);
1143         return Collections.unmodifiableList(exp);
1144     }
1145 
1146     private static double[] arrayDoubleRange(int upTo) {
1147         double[] exp = new double[upTo];
1148         for (int i = 0; i < upTo; i++)
1149             exp[i] = i;
1150         return exp;
1151     }
1152 
1153     @Test(dataProvider = "Spliterator.OfDouble")
1154     public void testDoubleNullPointerException(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1155         executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((DoubleConsumer) null));
1156         executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((DoubleConsumer) null));
1157     }
1158 
1159     @Test(dataProvider = "Spliterator.OfDouble")
1160     public void testDoubleForEach(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1161         testForEach(exp, s, doubleBoxingConsumer());
1162     }
1163 
1164     @Test(dataProvider = "Spliterator.OfDouble")
1165     public void testDoubleTryAdvance(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1166         testTryAdvance(exp, s, doubleBoxingConsumer());
1167     }
1168 
1169     @Test(dataProvider = "Spliterator.OfDouble")
1170     public void testDoubleMixedTryAdvanceForEach(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1171         testMixedTryAdvanceForEach(exp, s, doubleBoxingConsumer());
1172     }
1173 
1174     @Test(dataProvider = "Spliterator.OfDouble")
1175     public void testDoubleMixedTraverseAndSplit(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1176         testMixedTraverseAndSplit(exp, s, doubleBoxingConsumer());




 649             if (size == 0) {
 650                 db.addMap(m -> Collections.<Integer, Integer>emptyMap());
 651             }
 652             else if (size == 1) {
 653                 db.addMap(m -> Collections.singletonMap(exp.get(0), exp.get(0)));
 654             }
 655         }
 656 
 657         return spliteratorDataProvider = data.toArray(new Object[0][]);
 658     }
 659 
 660     private static List<Integer> listIntRange(int upTo) {
 661         List<Integer> exp = new ArrayList<>();
 662         for (int i = 0; i < upTo; i++)
 663             exp.add(i);
 664         return Collections.unmodifiableList(exp);
 665     }
 666 
 667     @Test(dataProvider = "Spliterator<Integer>")
 668     public void testNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 669         assertThrowsNPE(() -> s.get().forEachRemaining(null));
 670         assertThrowsNPE(() -> s.get().tryAdvance(null));
 671     }
 672 
 673     @Test(dataProvider = "Spliterator<Integer>")
 674     public void testForEach(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 675         testForEach(exp, s, UnaryOperator.identity());
 676     }
 677 
 678     @Test(dataProvider = "Spliterator<Integer>")
 679     public void testTryAdvance(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 680         testTryAdvance(exp, s, UnaryOperator.identity());
 681     }
 682 
 683     @Test(dataProvider = "Spliterator<Integer>")
 684     public void testMixedTryAdvanceForEach(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 685         testMixedTryAdvanceForEach(exp, s, UnaryOperator.identity());
 686     }
 687 
 688     @Test(dataProvider = "Spliterator<Integer>")
 689     public void testMixedTraverseAndSplit(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
 690         testMixedTraverseAndSplit(exp, s, UnaryOperator.identity());


 849             SpliteratorOfIntCharDataBuilder cdb = new SpliteratorOfIntCharDataBuilder(data, string);
 850             cdb.add("\"%s\"", s -> s);
 851             cdb.add("new CharSequenceImpl(\"%s\")", CharSequenceImpl::new);
 852             cdb.add("new StringBuilder(\"%s\")", StringBuilder::new);
 853             cdb.add("new StringBuffer(\"%s\")", StringBuffer::new);
 854             cdb.add("CharBuffer.wrap(\"%s\".toCharArray())", s -> CharBuffer.wrap(s.toCharArray()));
 855         }
 856 
 857         return spliteratorOfIntDataProvider = data.toArray(new Object[0][]);
 858     }
 859 
 860     private static int[] arrayIntRange(int upTo) {
 861         int[] exp = new int[upTo];
 862         for (int i = 0; i < upTo; i++)
 863             exp[i] = i;
 864         return exp;
 865     }
 866 
 867     @Test(dataProvider = "Spliterator.OfInt")
 868     public void testIntNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 869         assertThrowsNPE(() -> s.get().forEachRemaining((IntConsumer) null));
 870         assertThrowsNPE(() -> s.get().tryAdvance((IntConsumer) null));
 871     }
 872 
 873     @Test(dataProvider = "Spliterator.OfInt")
 874     public void testIntForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 875         testForEach(exp, s, intBoxingConsumer());
 876     }
 877 
 878     @Test(dataProvider = "Spliterator.OfInt")
 879     public void testIntTryAdvance(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 880         testTryAdvance(exp, s, intBoxingConsumer());
 881     }
 882 
 883     @Test(dataProvider = "Spliterator.OfInt")
 884     public void testIntMixedTryAdvanceForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 885         testMixedTryAdvanceForEach(exp, s, intBoxingConsumer());
 886     }
 887 
 888     @Test(dataProvider = "Spliterator.OfInt")
 889     public void testIntMixedTraverseAndSplit(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
 890         testMixedTraverseAndSplit(exp, s, intBoxingConsumer());


 992 
 993         return spliteratorOfLongDataProvider = data.toArray(new Object[0][]);
 994     }
 995 
 996     private static List<Long> listLongRange(int upTo) {
 997         List<Long> exp = new ArrayList<>();
 998         for (long i = 0; i < upTo; i++)
 999             exp.add(i);
1000         return Collections.unmodifiableList(exp);
1001     }
1002 
1003     private static long[] arrayLongRange(int upTo) {
1004         long[] exp = new long[upTo];
1005         for (int i = 0; i < upTo; i++)
1006             exp[i] = i;
1007         return exp;
1008     }
1009 
1010     @Test(dataProvider = "Spliterator.OfLong")
1011     public void testLongNullPointerException(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1012         assertThrowsNPE(() -> s.get().forEachRemaining((LongConsumer) null));
1013         assertThrowsNPE(() -> s.get().tryAdvance((LongConsumer) null));
1014     }
1015 
1016     @Test(dataProvider = "Spliterator.OfLong")
1017     public void testLongForEach(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1018         testForEach(exp, s, longBoxingConsumer());
1019     }
1020 
1021     @Test(dataProvider = "Spliterator.OfLong")
1022     public void testLongTryAdvance(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1023         testTryAdvance(exp, s, longBoxingConsumer());
1024     }
1025 
1026     @Test(dataProvider = "Spliterator.OfLong")
1027     public void testLongMixedTryAdvanceForEach(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1028         testMixedTryAdvanceForEach(exp, s, longBoxingConsumer());
1029     }
1030 
1031     @Test(dataProvider = "Spliterator.OfLong")
1032     public void testLongMixedTraverseAndSplit(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
1033         testMixedTraverseAndSplit(exp, s, longBoxingConsumer());


1135 
1136         return spliteratorOfDoubleDataProvider = data.toArray(new Object[0][]);
1137     }
1138 
1139     private static List<Double> listDoubleRange(int upTo) {
1140         List<Double> exp = new ArrayList<>();
1141         for (double i = 0; i < upTo; i++)
1142             exp.add(i);
1143         return Collections.unmodifiableList(exp);
1144     }
1145 
1146     private static double[] arrayDoubleRange(int upTo) {
1147         double[] exp = new double[upTo];
1148         for (int i = 0; i < upTo; i++)
1149             exp[i] = i;
1150         return exp;
1151     }
1152 
1153     @Test(dataProvider = "Spliterator.OfDouble")
1154     public void testDoubleNullPointerException(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1155         assertThrowsNPE(() -> s.get().forEachRemaining((DoubleConsumer) null));
1156         assertThrowsNPE(() -> s.get().tryAdvance((DoubleConsumer) null));
1157     }
1158 
1159     @Test(dataProvider = "Spliterator.OfDouble")
1160     public void testDoubleForEach(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1161         testForEach(exp, s, doubleBoxingConsumer());
1162     }
1163 
1164     @Test(dataProvider = "Spliterator.OfDouble")
1165     public void testDoubleTryAdvance(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1166         testTryAdvance(exp, s, doubleBoxingConsumer());
1167     }
1168 
1169     @Test(dataProvider = "Spliterator.OfDouble")
1170     public void testDoubleMixedTryAdvanceForEach(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1171         testMixedTryAdvanceForEach(exp, s, doubleBoxingConsumer());
1172     }
1173 
1174     @Test(dataProvider = "Spliterator.OfDouble")
1175     public void testDoubleMixedTraverseAndSplit(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
1176         testMixedTraverseAndSplit(exp, s, doubleBoxingConsumer());


< prev index next >