algorithms-sandbox/sorting/java/test/be/brainbaking/sorting/SortTest.java

37 lines
795 B
Java
Raw Normal View History

2018-03-21 20:45:02 +01:00
package be.brainbaking.sorting;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
public class SortTest {
2018-03-24 11:04:55 +01:00
@Test
public void bucketSort() {
simpleTestCaseFor(new BucketSort());
}
2018-03-23 15:29:08 +01:00
@Test
public void quickSort() {
simpleTestCaseFor(new QuickSort());
2018-03-23 15:29:08 +01:00
}
@Test
public void heapSort() {
simpleTestCaseFor(new HeapSort());
}
2018-03-21 20:45:02 +01:00
@Test
public void insertionSort() {
simpleTestCaseFor(new InsertionSort());
}
private void simpleTestCaseFor(Sortable sorter) {
List<Integer> result = sorter.sort(Arrays.asList(4, 2, 3, 1, 6, 5));
Assertions.assertArrayEquals(Arrays.asList(1, 2, 3, 4, 5, 6).toArray(), result.toArray());
}
}