diff --git a/app/src/test/java/de/uni_marburg/powersort/sort/AbstractSortTest.java b/app/src/test/java/de/uni_marburg/powersort/sort/AbstractSortTest.java index 7fde10e..b058a10 100644 --- a/app/src/test/java/de/uni_marburg/powersort/sort/AbstractSortTest.java +++ b/app/src/test/java/de/uni_marburg/powersort/sort/AbstractSortTest.java @@ -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); }