File tree 2 files changed +14
-1
lines changed
main/java/com/thealgorithms/sorts
test/java/com/thealgorithms/sorts
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class DarkSort implements SortAlgorithm {
19
19
* @return sorted array
20
20
*/
21
21
@ Override
22
+
22
23
public <T extends Comparable <T >> T [] sort (T [] unsorted ) {
23
24
if (unsorted == null || unsorted .length <= 1 ) {
24
25
return unsorted ;
Original file line number Diff line number Diff line change 2
2
3
3
import org .junit .jupiter .api .Test ;
4
4
5
- import static org .junit .jupiter .api .Assertions .*;
5
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
6
+ import static org .junit .jupiter .api .Assertions .assertNull ;
6
7
7
8
class DarkSortTest {
8
9
@@ -60,4 +61,15 @@ void testAlreadySortedArray() {
60
61
61
62
assertArrayEquals (expected , sorted );
62
63
}
64
+
65
+ @ Test
66
+ void testNullArray () {
67
+ Integer [] unsorted = null ;
68
+
69
+ DarkSort darkSort = new DarkSort ();
70
+ Integer [] sorted = darkSort .sort (unsorted );
71
+
72
+ assertNull (sorted , "Sorting a null array should return null" );
73
+ }
74
+
63
75
}
You can’t perform that action at this time.
0 commit comments