add sort test

This commit is contained in:
Daniel Langbein 2024-12-17 08:26:56 +00:00
parent e182ecc756
commit a782d8c1fa
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002

View File

@ -2,6 +2,7 @@ package de.uni_marburg.powersort.sort;
import de.uni_marburg.powersort.JUnitUtil; import de.uni_marburg.powersort.JUnitUtil;
import de.uni_marburg.powersort.data.AscendingRuns; import de.uni_marburg.powersort.data.AscendingRuns;
import de.uni_marburg.powersort.data.DescendingIntegers;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.converter.ConvertWith;
import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.CsvSource;
@ -17,9 +18,8 @@ public abstract class AbstractSortTest {
@CsvSource({ @CsvSource({
"''", "''",
"1337", "1337",
"3|2|1", "|2|3|1",
"1|1", "1|1",
"2|1",
"2|1|2", "2|1|2",
}) })
void test1(@ConvertWith(JUnitUtil.IntegerArrayConverter.class) Integer[] array) { void test1(@ConvertWith(JUnitUtil.IntegerArrayConverter.class) Integer[] array) {
@ -35,6 +35,17 @@ public abstract class AbstractSortTest {
Integer[] array = AscendingRuns.newAscendingRuns(numOfRuns, runLength, decreaseBetweenRuns).getCopy(); Integer[] array = AscendingRuns.newAscendingRuns(numOfRuns, runLength, decreaseBetweenRuns).getCopy();
sortAndCheckResult(array); sortAndCheckResult(array);
} }
@ParameterizedTest
@CsvSource({
"2",
"3",
"13",
"1337",
})
void test2(int size) {
Integer[] array = new DescendingIntegers(size).getCopy();
sortAndCheckResult(array);
}
void sortAndCheckResult(Integer[] array){ void sortAndCheckResult(Integer[] array){
Integer[] expected = Arrays.copyOf(array, array.length); Integer[] expected = Arrays.copyOf(array, array.length);