Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/com/thealgorithms/sorts/BitonicSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ private enum Direction {
*/
@Override
public <T extends Comparable<T>> T[] sort(T[] array) {
if (array == null) {
throw new IllegalArgumentException("Array must not be null");
}
if (array.length == 0) {
return array;
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/thealgorithms/sorts/BitonicSortTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.thealgorithms.sorts;

import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

public class BitonicSortTest extends SortingAlgorithmTest {
@Override
SortAlgorithm getSortAlgorithm() {
return new BitonicSort();
}

@Test
void testNullArrayThrowsIllegalArgumentException() {
assertThrows(IllegalArgumentException.class, () -> getSortAlgorithm().sort((Integer[]) null));
}
}
Loading