Added test cases to OddEvenSort. (#3768)

* Add testcase to CocktailShakerSort Algorithm

* fixed method name to lowerCamelCase

* Added test cases to OddEvenSortTest
This commit is contained in:
김준홍 2022-11-18 22:04:34 +09:00 committed by GitHub
parent ac71f6eb79
commit 9f78d1fcf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,39 @@
package com.thealgorithms.sorts;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
/**
* @author Tabbygray (https://github.com/Tabbygray)
* @see OddEvenSort
*/
public class OddEvenSortTest {
private OddEvenSort oddEvenSort = new OddEvenSort();
@Test
public void oddEvenSortEmptyArray(){
int[] inputArray = {};
oddEvenSort.oddEvenSort(inputArray);
int[] expectedOutput = {};
assertArrayEquals(inputArray, expectedOutput);
}
@Test
public void oddEvenSortNaturalNumberArray(){
int[] inputArray = {18, 91, 86, 60, 21, 44, 37, 78, 98, 67};
oddEvenSort.oddEvenSort(inputArray);
int[] expectedOutput = {18, 21, 37, 44, 60, 67, 78, 86, 91, 98};
assertArrayEquals(inputArray, expectedOutput);
}
@Test
public void oddEvenSortIntegerArray(){
int[] inputArray = {57, 69, -45, 12, -85, 3, -76, 36, 67, -14};
oddEvenSort.oddEvenSort(inputArray);
int[] expectedOutput = {-85, -76, -45, -14, 3, 12, 36, 57, 67, 69};
assertArrayEquals(inputArray, expectedOutput);
}
}