1
1
package com .thealgorithms .sorts ;
2
2
3
3
import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
4
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4
5
5
6
import java .util .stream .Stream ;
7
+
8
+ import org .junit .jupiter .api .Test ;
6
9
import org .junit .jupiter .params .ParameterizedTest ;
7
10
import org .junit .jupiter .params .provider .Arguments ;
8
11
import org .junit .jupiter .params .provider .MethodSource ;
@@ -18,9 +21,11 @@ private static Stream<Arguments> provideTestCases() {
18
21
return Stream .of (Arguments .of (new int [] {170 , 45 , 75 , 90 , 802 , 24 , 2 , 66 }, new int [] {2 , 24 , 45 , 66 , 75 , 90 , 170 , 802 }), Arguments .of (new int [] {3 , 3 , 3 , 3 }, new int [] {3 , 3 , 3 , 3 }), Arguments .of (new int [] {9 , 4 , 6 , 8 , 14 , 3 }, new int [] {3 , 4 , 6 , 8 , 9 , 14 }),
19
22
Arguments .of (new int [] {10 , 90 , 49 , 2 , 1 , 5 , 23 }, new int [] {1 , 2 , 5 , 10 , 23 , 49 , 90 }), Arguments .of (new int [] {1 , 3 , 4 , 2 , 7 , 8 }, new int [] {1 , 2 , 3 , 4 , 7 , 8 }), Arguments .of (new int [] {}, new int [] {}), Arguments .of (new int [] {1 }, new int [] {1 }),
20
23
Arguments .of (new int [] {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }, new int [] {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }), Arguments .of (new int [] {9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 }, new int [] {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }),
21
- Arguments .of (new int [] {1000000000 , 999999999 , 888888888 , 777777777 }, new int [] {777777777 , 888888888 , 999999999 , 1000000000 }), Arguments .of (new int [] {123 , 9 , 54321 , 123456789 , 0 }, new int [] {0 , 9 , 123 , 54321 , 123456789 }),
22
- Arguments .of (new int [] {-170 , 45 , -75 , 90 , -802 , 24 , -2 , 66 }, new int [] {-802 , -170 , -75 , -2 , 24 , 45 , 66 , 90 }), Arguments .of (new int [] {-3 , -3 , -3 , -3 }, new int [] {-3 , -3 , -3 , -3 }), Arguments .of (new int [] {-9 , -4 , -6 , -8 , -14 , -3 }, new int [] {-14 , -9 , -8 , -6 , -4 , -3 }),
23
- Arguments .of (new int [] {10 , -90 , 49 , -2 , 1 , -5 , 23 }, new int [] {-90 , -5 , -2 , 1 , 10 , 23 , 49 }), Arguments .of (new int [] {-1 , -3 , -4 , -2 , -7 , -8 }, new int [] {-8 , -7 , -4 , -3 , -2 , -1 }), Arguments .of (new int [] {1 , -1 , 0 , -100 , 100 }, new int [] {-100 , -1 , 0 , 1 , 100 }),
24
- Arguments .of (new int [] {-1000000000 , 999999999 , -888888888 , 777777777 }, new int [] {-1000000000 , -888888888 , 777777777 , 999999999 }), Arguments .of (new int [] {-123 , 9 , -54321 , 123456789 , 0 }, new int [] {-54321 , -123 , 0 , 9 , 123456789 }));
24
+ Arguments .of (new int [] {1000000000 , 999999999 , 888888888 , 777777777 }, new int [] {777777777 , 888888888 , 999999999 , 1000000000 }), Arguments .of (new int [] {123 , 9 , 54321 , 123456789 , 0 }, new int [] {0 , 9 , 123 , 54321 , 123456789 }));
25
+ }
26
+
27
+ @ Test
28
+ public void testWithNegativeNumbers () {
29
+ assertThrows (IllegalArgumentException .class , () -> RadixSort .sort (new int [] {3 , 1 , 4 , 1 , 5 , -9 }));
25
30
}
26
31
}
0 commit comments