-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathRadixSortTest.java
More file actions
59 lines (46 loc) · 1.83 KB
/
RadixSortTest.java
File metadata and controls
59 lines (46 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
class RadixSortTest {
@Test
void testRadixSortWithPositiveNumbers() {
int[] input = {170, 45, 75, 90, 802, 24, 2, 66};
int[] expected = {2, 24, 45, 66, 75, 90, 170, 802};
Radix.radixsort(input, input.length);
assertArrayEquals(expected, input, "The sorted array does not match the expected output");
}
@Test
void testRadixSortWithAllEqualNumbers() {
int[] input = {5, 5, 5, 5, 5};
int[] expected = {5, 5, 5, 5, 5};
Radix.radixsort(input, input.length);
assertArrayEquals(expected, input, "The sorted array does not match the expected output");
}
@Test
void testRadixSortWithSingleElement() {
int[] input = {42};
int[] expected = {42};
Radix.radixsort(input, input.length);
assertArrayEquals(expected, input, "The sorted array does not match the expected output");
}
@Test
void testRadixSortWithAlreadySortedArray() {
int[] input = {1, 2, 3, 4, 5};
int[] expected = {1, 2, 3, 4, 5};
Radix.radixsort(input, input.length);
assertArrayEquals(expected, input, "The sorted array does not match the expected output");
}
@Test
void testRadixSortWithDescendingArray() {
int[] input = {9, 8, 7, 6, 5, 4, 3, 2, 1};
int[] expected = {1, 2, 3, 4, 5, 6, 7, 8, 9};
Radix.radixsort(input, input.length);
assertArrayEquals(expected, input, "The sorted array does not match the expected output");
}
@Test
void testRadixSortWithEmptyArray() {
int[] input = {};
int[] expected = {};
Radix.radixsort(input, input.length);
assertArrayEquals(expected, input, "The sorted array does not match the expected output");
}
}