8174171: Move spliterator testing of BitSet into big memory tests BitSetStreamTest
Reviewed-by: mli, psandoz
This commit is contained in:
parent
d58ce97583
commit
ffed03c6d9
@ -280,8 +280,6 @@ com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-
|
|||||||
|
|
||||||
# jdk_util
|
# jdk_util
|
||||||
|
|
||||||
java/util/BitSet/BitSetStreamTest.java 8079538 generic-all
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# jdk_instrument
|
# jdk_instrument
|
||||||
|
@ -18,7 +18,7 @@ keys=2d dnd i18n intermittent randomness headful
|
|||||||
othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces javax/xml/jaxp/testng/validation java/lang/ProcessHandle
|
othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces javax/xml/jaxp/testng/validation java/lang/ProcessHandle
|
||||||
|
|
||||||
# Tests that cannot run concurrently
|
# Tests that cannot run concurrently
|
||||||
exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi java/util/stream javax/rmi com/sun/corba/cachedSocket
|
exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi java/util/stream java/util/BitSet/stream javax/rmi com/sun/corba/cachedSocket
|
||||||
|
|
||||||
# Group definitions
|
# Group definitions
|
||||||
groups=TEST.groups [closed/TEST.groups]
|
groups=TEST.groups [closed/TEST.groups]
|
||||||
|
@ -714,7 +714,7 @@ needs_compact2 = \
|
|||||||
java/security/BasicPermission/Wildcard.java \
|
java/security/BasicPermission/Wildcard.java \
|
||||||
java/util/Arrays/ParallelPrefix.java \
|
java/util/Arrays/ParallelPrefix.java \
|
||||||
java/util/Arrays/SetAllTest.java \
|
java/util/Arrays/SetAllTest.java \
|
||||||
java/util/BitSet/BitSetStreamTest.java \
|
java/util/BitSet/stream/BitSetStreamTest.java \
|
||||||
java/util/Collection/CollectionDefaults.java \
|
java/util/Collection/CollectionDefaults.java \
|
||||||
java/util/Collections/CheckedIdentityMap.java \
|
java/util/Collections/CheckedIdentityMap.java \
|
||||||
java/util/Collections/CheckedMapBash.java \
|
java/util/Collections/CheckedMapBash.java \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -21,32 +21,40 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.BitSet;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.PrimitiveIterator;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Spliterator;
|
||||||
|
import java.util.SpliteratorOfIntDataBuilder;
|
||||||
|
import java.util.SpliteratorTestHelper;
|
||||||
|
import java.util.function.IntConsumer;
|
||||||
|
import java.util.function.IntSupplier;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.lang.Integer;
|
import static java.util.stream.Collectors.toList;
|
||||||
import java.lang.Object;
|
|
||||||
import java.lang.System;
|
|
||||||
import java.util.BitSet;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
import java.util.PrimitiveIterator;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.function.IntSupplier;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @summary test BitSet stream
|
* @summary test BitSet stream
|
||||||
* @bug 8012645 8076442
|
* @bug 8012645 8076442
|
||||||
* @run testng BitSetStreamTest
|
* @requires os.maxMemory >= 2g
|
||||||
|
* @library ../../stream/bootlib
|
||||||
|
* @build java.base/java.util.SpliteratorTestHelper
|
||||||
|
* java.base/java.util.SpliteratorOfIntDataBuilder
|
||||||
|
* @run testng/othervm -Xms512m -Xmx1024m BitSetStreamTest
|
||||||
*/
|
*/
|
||||||
public class BitSetStreamTest {
|
public class BitSetStreamTest extends SpliteratorTestHelper {
|
||||||
static class Fibs implements IntSupplier {
|
static class Fibs implements IntSupplier {
|
||||||
private int n1 = 0;
|
private int n1 = 0;
|
||||||
private int n2 = 1;
|
private int n2 = 1;
|
||||||
@ -118,6 +126,91 @@ public class BitSetStreamTest {
|
|||||||
assertFalse(it.hasNext());
|
assertFalse(it.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Object[][] spliteratorOfIntDataProvider;
|
||||||
|
|
||||||
|
@DataProvider(name = "BitSet.stream.spliterator")
|
||||||
|
public static Object[][] spliteratorOfIntDataProvider() {
|
||||||
|
if (spliteratorOfIntDataProvider != null) {
|
||||||
|
return spliteratorOfIntDataProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Object[]> data = new ArrayList<>();
|
||||||
|
|
||||||
|
Object[][] bitStreamTestcases = new Object[][] {
|
||||||
|
{ "none", IntStream.empty().toArray() },
|
||||||
|
{ "index 0", IntStream.of(0).toArray() },
|
||||||
|
{ "index 255", IntStream.of(255).toArray() },
|
||||||
|
{ "index 0 and 255", IntStream.of(0, 255).toArray() },
|
||||||
|
{ "index Integer.MAX_VALUE", IntStream.of(Integer.MAX_VALUE).toArray() },
|
||||||
|
{ "index Integer.MAX_VALUE - 1", IntStream.of(Integer.MAX_VALUE - 1).toArray() },
|
||||||
|
{ "index 0 and Integer.MAX_VALUE", IntStream.of(0, Integer.MAX_VALUE).toArray() },
|
||||||
|
{ "every bit", IntStream.range(0, 255).toArray() },
|
||||||
|
{ "step 2", IntStream.range(0, 255).map(f -> f * 2).toArray() },
|
||||||
|
{ "step 3", IntStream.range(0, 255).map(f -> f * 3).toArray() },
|
||||||
|
{ "step 5", IntStream.range(0, 255).map(f -> f * 5).toArray() },
|
||||||
|
{ "step 7", IntStream.range(0, 255).map(f -> f * 7).toArray() },
|
||||||
|
{ "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000).toArray() },
|
||||||
|
};
|
||||||
|
for (Object[] tc : bitStreamTestcases) {
|
||||||
|
String description = (String)tc[0];
|
||||||
|
int[] exp = (int[])tc[1];
|
||||||
|
SpliteratorOfIntDataBuilder db = new SpliteratorOfIntDataBuilder(
|
||||||
|
data, IntStream.of(exp).boxed().collect(toList()));
|
||||||
|
|
||||||
|
db.add("BitSet.stream.spliterator() {" + description + "}", () ->
|
||||||
|
IntStream.of(exp).collect(BitSet::new, BitSet::set, BitSet::or).
|
||||||
|
stream().spliterator()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return spliteratorOfIntDataProvider = data.toArray(new Object[0][]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((IntConsumer) null));
|
||||||
|
executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((IntConsumer) null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testForEach(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntTryAdvance(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testTryAdvance(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntMixedTryAdvanceForEach(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testMixedTryAdvanceForEach(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntMixedTraverseAndSplit(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testMixedTraverseAndSplit(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntSplitAfterFullTraversal(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testSplitAfterFullTraversal(s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntSplitOnce(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testSplitOnce(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntSplitSixDeep(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testSplitSixDeep(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "BitSet.stream.spliterator")
|
||||||
|
public void testIntSplitUntilNull(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
|
||||||
|
testSplitUntilNull(exp, s, intBoxingConsumer());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRandomStream() {
|
public void testRandomStream() {
|
||||||
final int size = 1024 * 1024;
|
final int size = 1024 * 1024;
|
@ -25,7 +25,8 @@
|
|||||||
* @test
|
* @test
|
||||||
* @summary Spliterator traversing and splitting tests
|
* @summary Spliterator traversing and splitting tests
|
||||||
* @library ../stream/bootlib
|
* @library ../stream/bootlib
|
||||||
* @build java.base/java.util.SpliteratorTestHelper
|
* @build java.base/java.util.SpliteratorOfIntDataBuilder
|
||||||
|
* java.base/java.util.SpliteratorTestHelper
|
||||||
* @run testng SpliteratorTraversingAndSplittingTest
|
* @run testng SpliteratorTraversingAndSplittingTest
|
||||||
* @bug 8020016 8071477 8072784 8169838
|
* @bug 8020016 8071477 8072784 8169838
|
||||||
*/
|
*/
|
||||||
@ -40,7 +41,6 @@ import java.util.AbstractSet;
|
|||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.BitSet;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -59,6 +59,7 @@ import java.util.RandomAccess;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
|
import java.util.SpliteratorOfIntDataBuilder;
|
||||||
import java.util.SpliteratorTestHelper;
|
import java.util.SpliteratorTestHelper;
|
||||||
import java.util.Spliterators;
|
import java.util.Spliterators;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
@ -84,9 +85,6 @@ import java.util.function.IntConsumer;
|
|||||||
import java.util.function.LongConsumer;
|
import java.util.function.LongConsumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper {
|
public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper {
|
||||||
|
|
||||||
@ -713,34 +711,6 @@ public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
private static class SpliteratorOfIntDataBuilder {
|
|
||||||
List<Object[]> data;
|
|
||||||
|
|
||||||
List<Integer> exp;
|
|
||||||
|
|
||||||
SpliteratorOfIntDataBuilder(List<Object[]> data, List<Integer> exp) {
|
|
||||||
this.data = data;
|
|
||||||
this.exp = exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void add(String description, List<Integer> expected, Supplier<Spliterator.OfInt> s) {
|
|
||||||
description = joiner(description).toString();
|
|
||||||
data.add(new Object[]{description, expected, s});
|
|
||||||
}
|
|
||||||
|
|
||||||
void add(String description, Supplier<Spliterator.OfInt> s) {
|
|
||||||
add(description, exp, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder joiner(String description) {
|
|
||||||
return new StringBuilder(description).
|
|
||||||
append(" {").
|
|
||||||
append("size=").append(exp.size()).
|
|
||||||
append("}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SpliteratorOfIntCharDataBuilder {
|
private static class SpliteratorOfIntCharDataBuilder {
|
||||||
List<Object[]> data;
|
List<Object[]> data;
|
||||||
|
|
||||||
@ -884,30 +854,6 @@ public class SpliteratorTraversingAndSplittingTest extends SpliteratorTestHelper
|
|||||||
cdb.add("CharBuffer.wrap(\"%s\".toCharArray())", s -> CharBuffer.wrap(s.toCharArray()));
|
cdb.add("CharBuffer.wrap(\"%s\".toCharArray())", s -> CharBuffer.wrap(s.toCharArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object[][] bitStreamTestcases = new Object[][] {
|
|
||||||
{ "none", IntStream.empty().toArray() },
|
|
||||||
{ "index 0", IntStream.of(0).toArray() },
|
|
||||||
{ "index 255", IntStream.of(255).toArray() },
|
|
||||||
{ "index 0 and 255", IntStream.of(0, 255).toArray() },
|
|
||||||
{ "every bit", IntStream.range(0, 255).toArray() },
|
|
||||||
{ "step 2", IntStream.range(0, 255).map(f -> f * 2).toArray() },
|
|
||||||
{ "step 3", IntStream.range(0, 255).map(f -> f * 3).toArray() },
|
|
||||||
{ "step 5", IntStream.range(0, 255).map(f -> f * 5).toArray() },
|
|
||||||
{ "step 7", IntStream.range(0, 255).map(f -> f * 7).toArray() },
|
|
||||||
{ "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000).toArray() },
|
|
||||||
};
|
|
||||||
for (Object[] tc : bitStreamTestcases) {
|
|
||||||
String description = (String)tc[0];
|
|
||||||
int[] exp = (int[])tc[1];
|
|
||||||
SpliteratorOfIntDataBuilder db = new SpliteratorOfIntDataBuilder(
|
|
||||||
data, IntStream.of(exp).boxed().collect(toList()));
|
|
||||||
|
|
||||||
db.add("BitSet.stream.spliterator() {" + description + "}", () ->
|
|
||||||
IntStream.of(exp).collect(BitSet::new, BitSet::set, BitSet::or).
|
|
||||||
stream().spliterator()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return spliteratorOfIntDataProvider = data.toArray(new Object[0][]);
|
return spliteratorOfIntDataProvider = data.toArray(new Object[0][]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package java.util;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class SpliteratorOfIntDataBuilder {
|
||||||
|
List<Object[]> data;
|
||||||
|
|
||||||
|
List<Integer> exp;
|
||||||
|
|
||||||
|
public SpliteratorOfIntDataBuilder(List<Object[]> data, List<Integer> exp) {
|
||||||
|
this.data = data;
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(String description, List<Integer> expected, Supplier<Spliterator.OfInt> s) {
|
||||||
|
description = joiner(description).toString();
|
||||||
|
data.add(new Object[]{description, expected, s});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(String description, Supplier<Spliterator.OfInt> s) {
|
||||||
|
add(description, exp, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder joiner(String description) {
|
||||||
|
return new StringBuilder(description).
|
||||||
|
append(" {").
|
||||||
|
append("size=").append(exp.size()).
|
||||||
|
append("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user