import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; public class SimpleTest { private static KGrootsteElementen k; @BeforeClass public static void init() { k = new KGrootsteElementenBepaler(); } @Test public void test1() { List input = new ArrayList<>(); for(int i = 0; i <= 1000; i++) { input.add(i); } List antw = k.bepaalKGrootsteElementen(Collections.unmodifiableList(input), 20); antw.sort(Comparator.naturalOrder()); Assert.assertEquals(input.subList(981, 1001), antw); } @Test public void test2() { List input = Arrays.asList(9, 92, 82, 85, 76, 30, 77, 89, 60); List antw = k.bepaalKGrootsteElementen(Collections.unmodifiableList(input), 12); antw.sort(Comparator.naturalOrder()); Assert.assertEquals(Arrays.asList(9, 30, 60, 76, 77, 82, 85, 89, 92), antw); } @Test public void test3() { List input = Arrays.asList(7, 46, 54, 98, 11, 58, 25, 11, 84, 97, 51, 22, 87, 12, 95, 64, 97, 98, 55, 2, 2, 22, 48, 68, 41, 55, 9, 15, 30, 97); List antw = k.bepaalKGrootsteElementen(Collections.unmodifiableList(input), 5); antw.sort(Comparator.naturalOrder()); Assert.assertEquals(Arrays.asList(97, 97, 97, 98, 98), antw); } @Test public void test4() { List input = Arrays.asList(99, 88, 79, 82, 49, 85, 21, 61, 59, 25, 54, 15, 57, 69, 15); List antw = k.bepaalKGrootsteElementen(Collections.unmodifiableList(input), 3); antw.sort(Comparator.naturalOrder()); Assert.assertEquals(Arrays.asList(85, 88, 99), antw); } @Test public void testEmpty() { Assert.assertEquals(Collections.emptyList(), k.bepaalKGrootsteElementen(Collections.emptyList(), 3)); } }