mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 22:43:30 +08:00
Add Introspective Search (#3887)
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
package com.thealgorithms.sorts;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class IntrospectiveSortTest {
|
||||
@Test
|
||||
// valid test case
|
||||
public void StrandSortNonDuplicateTest() {
|
||||
Integer[] expectedArray = {1, 2, 3, 4, 5};
|
||||
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
|
||||
assertArrayEquals(expectedArray, actualList);
|
||||
}
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void StrandSortDuplicateTest() {
|
||||
Integer[] expectedArray = {2, 2, 2, 5, 7};
|
||||
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
|
||||
assertArrayEquals(expectedArray, actualList);
|
||||
}
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void StrandSortEmptyTest() {
|
||||
Integer[] expectedArray = {};
|
||||
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
|
||||
assertArrayEquals(expectedArray, actualList);
|
||||
}
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void StrandSortNullTest() {
|
||||
Integer[] expectedArray = null;
|
||||
assertThrows(NullPointerException.class, () -> {
|
||||
new IntrospectiveSort().sort(expectedArray);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void StrandSortNegativeTest() {
|
||||
Integer[] expectedArray = {-1, -2, -3, -4, -5};
|
||||
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
|
||||
assertArrayEquals(expectedArray, actualList);
|
||||
}
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void StrandSortNegativeAndPositiveTest() {
|
||||
Integer[] expectedArray = {-1, -2, -3, 4, 5};
|
||||
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
|
||||
assertArrayEquals(expectedArray, actualList);
|
||||
}
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void allSameTest() {
|
||||
Integer[] expectedArray = {1, 1, 1, 1, 1};
|
||||
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
|
||||
assertArrayEquals(expectedArray, actualList);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user