--- a/jdk/test/java/util/Arrays/ParallelPrefix.java Thu Jun 04 19:00:56 2015 +0100
+++ b/jdk/test/java/util/Arrays/ParallelPrefix.java Thu Jun 04 19:28:45 2015 +0100
@@ -51,7 +51,7 @@
private final static int MEDIUM_ARRAY_SIZE = 1 << 8;
//Array size much greater than MIN_PARTITION
- private final static int LARGE_ARRAY_SIZE = 1 << 12;
+ private final static int LARGE_ARRAY_SIZE = 1 << 14;
private final static int[] ARRAY_SIZE_COLLECTION = new int[]{
SMALL_ARRAY_SIZE,
@@ -60,7 +60,7 @@
LARGE_ARRAY_SIZE
};
- @DataProvider
+ @DataProvider(name = "intSet")
public static Object[][] intSet(){
return genericData(size -> IntStream.range(0, size).toArray(),
new IntBinaryOperator[]{
@@ -68,7 +68,7 @@
Integer::min});
}
- @DataProvider
+ @DataProvider(name = "longSet")
public static Object[][] longSet(){
return genericData(size -> LongStream.range(0, size).toArray(),
new LongBinaryOperator[]{
@@ -76,7 +76,7 @@
Long::min});
}
- @DataProvider
+ @DataProvider(name = "doubleSet")
public static Object[][] doubleSet(){
return genericData(size -> IntStream.range(0, size).mapToDouble(i -> (double)i).toArray(),
new DoubleBinaryOperator[]{
@@ -84,7 +84,7 @@
Double::min});
}
- @DataProvider
+ @DataProvider(name = "stringSet")
public static Object[][] stringSet(){
Function<Integer, String[]> stringsFunc = size ->
IntStream.range(0, size).mapToObj(Integer::toString).toArray(String[]::new);
@@ -121,11 +121,11 @@
int[] parallelResult = data.clone();
Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op);
- assertEquals(parallelResult, sequentialResult);
+ assertArraysEqual(parallelResult, sequentialResult);
int[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex);
Arrays.parallelPrefix(parallelRangeResult, op);
- assertEquals(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
+ assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
}
@Test(dataProvider="longSet")
@@ -137,11 +137,11 @@
long[] parallelResult = data.clone();
Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op);
- assertEquals(parallelResult, sequentialResult);
+ assertArraysEqual(parallelResult, sequentialResult);
long[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex);
Arrays.parallelPrefix(parallelRangeResult, op);
- assertEquals(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
+ assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
}
@Test(dataProvider="doubleSet")
@@ -153,11 +153,11 @@
double[] parallelResult = data.clone();
Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op);
- assertEquals(parallelResult, sequentialResult);
+ assertArraysEqual(parallelResult, sequentialResult);
double[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex);
Arrays.parallelPrefix(parallelRangeResult, op);
- assertEquals(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
+ assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
}
@Test(dataProvider="stringSet")
@@ -169,11 +169,11 @@
String[] parallelResult = data.clone();
Arrays.parallelPrefix(parallelResult, fromIndex, toIndex, op);
- assertEquals(parallelResult, sequentialResult);
+ assertArraysEqual(parallelResult, sequentialResult);
String[] parallelRangeResult = Arrays.copyOfRange(data, fromIndex, toIndex);
Arrays.parallelPrefix(parallelRangeResult, op);
- assertEquals(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
+ assertArraysEqual(parallelRangeResult, Arrays.copyOfRange(sequentialResult, fromIndex, toIndex));
}
@Test
@@ -293,5 +293,41 @@
public static void assertInstance(Object actual, Class<?> expected, String message) {
assertTrue(expected.isInstance(actual), message);
}
+
+ static void assertArraysEqual(int[] actual, int[] expected) {
+ try {
+ assertEquals(actual, expected, "");
+ } catch (AssertionError x) {
+ throw new AssertionError(String.format("Expected:%s, actual:%s",
+ Arrays.toString(expected), Arrays.toString(actual)), x);
+ }
+ }
+
+ static void assertArraysEqual(long[] actual, long[] expected) {
+ try {
+ assertEquals(actual, expected, "");
+ } catch (AssertionError x) {
+ throw new AssertionError(String.format("Expected:%s, actual:%s",
+ Arrays.toString(expected), Arrays.toString(actual)), x);
+ }
+ }
+
+ static void assertArraysEqual(double[] actual, double[] expected) {
+ try {
+ assertEquals(actual, expected, "");
+ } catch (AssertionError x) {
+ throw new AssertionError(String.format("Expected:%s, actual:%s",
+ Arrays.toString(expected), Arrays.toString(actual)), x);
+ }
+ }
+
+ static void assertArraysEqual(String[] actual, String[] expected) {
+ try {
+ assertEquals(actual, expected, "");
+ } catch (AssertionError x) {
+ throw new AssertionError(String.format("Expected:%s, actual:%s",
+ Arrays.toString(expected), Arrays.toString(actual)), x);
+ }
+ }
}