Refactoring and code improving for OddEvenSort (#5242)

* Refactoring and code improving for OddEvenSort, changing it according to SortAlgorithm approach, also applying SortUtils

* Fix checkstyle

* Remove redundant main, remove redundant tests.

---------

Co-authored-by: alx <alx@alx.com>
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
Alex K
2024-06-20 09:26:09 +03:00
committed by GitHub
parent a9db8428b2
commit 91101ec424
2 changed files with 24 additions and 73 deletions

View File

@ -1,36 +1,15 @@
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 {
@Test
public void oddEvenSortEmptyArray() {
int[] inputArray = {};
OddEvenSort.oddEvenSort(inputArray);
int[] expectedOutput = {};
assertArrayEquals(inputArray, expectedOutput);
}
public class OddEvenSortTest extends SortingAlgorithmTest {
private final OddEvenSort oddEvenSort = new OddEvenSort();
@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);
@Override
SortAlgorithm getSortAlgorithm() {
return oddEvenSort;
}
}