mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
add sort test
This commit is contained in:
parent
ccd0fba7c2
commit
d19d89006c
@ -1,10 +1,13 @@
|
||||
package de.uni_marburg.powersort.sort;
|
||||
|
||||
import de.uni_marburg.powersort.JUnitUtil;
|
||||
import de.uni_marburg.powersort.data.AscendingRuns;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
public abstract class AbstractSortTest {
|
||||
@ -12,14 +15,31 @@ public abstract class AbstractSortTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"'',''",
|
||||
"'1337','1337'",
|
||||
"'3|2|1','1|2|3'",
|
||||
"'1|1','1|1'",
|
||||
"'2|1','1|2'",
|
||||
"'2|1|2','1|2|2'",
|
||||
"''",
|
||||
"1337",
|
||||
"3|2|1",
|
||||
"1|1",
|
||||
"2|1",
|
||||
"2|1|2",
|
||||
})
|
||||
void test1(@ConvertWith(JUnitUtil.IntegerArrayConverter.class) Integer[] array, @ConvertWith(JUnitUtil.IntegerArrayConverter.class) Integer[] expected) {
|
||||
void test1(@ConvertWith(JUnitUtil.IntegerArrayConverter.class) Integer[] array) {
|
||||
sortAndCheckResult(array);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"3,7,-13",
|
||||
"3,7,-3",
|
||||
})
|
||||
void test2(int numOfRuns, int runLength, int decreaseBetweenRuns) {
|
||||
Integer[] array = AscendingRuns.newAscendingRuns(numOfRuns, runLength, decreaseBetweenRuns).getCopy();
|
||||
sortAndCheckResult(array);
|
||||
}
|
||||
|
||||
void sortAndCheckResult(Integer[] array){
|
||||
Integer[] expected = Arrays.copyOf(array, array.length);
|
||||
Arrays.sort(expected);
|
||||
|
||||
sortAlg.get().sort(array);
|
||||
assertArrayEquals(expected, array);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user