Skip to content

Commit 551f09a

Browse files
committed
Added the unit test for parallelSort(int[])
1 parent edb5198 commit 551f09a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/com/github/coderodde/util/ParallelRadixSortTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,32 @@ public void testSerialRadixSort() {
7878
assertTrue(Arrays.equals(array1, array2));
7979
}
8080

81+
82+
@Test
83+
public void testParallelRadixSort() {
84+
Random random = new Random(29);
85+
86+
final int SIZE = 5_000_000;
87+
88+
int[] array1 = Utils.createRandomIntArray(
89+
SIZE,
90+
Integer.MAX_VALUE - 1,
91+
random);
92+
93+
int[] array2 = array1.clone();
94+
95+
final int FROM_INDEX = 13;
96+
final int TO_INDEX = SIZE - 15;
97+
98+
Arrays.sort(array1, FROM_INDEX, TO_INDEX);
99+
ParallelRadixSort.parallelSort(
100+
array2,
101+
FROM_INDEX,
102+
TO_INDEX);
103+
104+
assertTrue(Arrays.equals(array1, array2));
105+
}
106+
81107
@Test
82108
public void bruteForceTestInsertionsort() {
83109
final int ITERATIONS = 200;

0 commit comments

Comments
 (0)