diff --git a/SQ-2021-H6/pom.xml b/SQ-2021-H6/pom.xml index b2c9884..5e05f87 100644 --- a/SQ-2021-H6/pom.xml +++ b/SQ-2021-H6/pom.xml @@ -11,7 +11,6 @@ UTF-8 1.7.0-M1 5.6.2 - 5.6.2 4.13.1 @@ -93,12 +92,6 @@ ${junit.version} test - - org.junit.vintage - junit-vintage-engine - ${junit.vintage.version} - test - diff --git a/SQ-2021-H6/src/test/java/org/usi/sq/util/CollectionUtilsTest.java b/SQ-2021-H6/src/test/java/org/usi/sq/util/CollectionUtilsTest.java index bebbdb7..79c1313 100644 --- a/SQ-2021-H6/src/test/java/org/usi/sq/util/CollectionUtilsTest.java +++ b/SQ-2021-H6/src/test/java/org/usi/sq/util/CollectionUtilsTest.java @@ -6,9 +6,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; -class CollectionUtilsTest { +public class CollectionUtilsTest { private static > void checkSort(List source, List expected) { List target = new ArrayList<>(source); @@ -20,14 +20,44 @@ class CollectionUtilsTest { return Arrays.asList(elements); } - private static ArrayList empty() { - return new ArrayList(); + @Test + public void checkSorted() { + assertThrows(IllegalArgumentException.class, () -> CollectionUtils.sort(null)); + checkSort(new ArrayList(), new ArrayList<>()); + checkSort(list(0, 1, 2, 3, 4), list(0, 1, 2, 3, 4)); + checkSort(list(8, 4, 5, 6, 7), list(4, 5, 6, 7, 8)); + checkSort(list(8, 7), list(7, 8)); } @Test - public void checkSorted() { - checkSort(empty(), empty()); - checkSort(list(0, 1, 2, 3, 4), list(0, 1, 2, 3, 4)); - checkSort(list(8, 4, 5, 6, 7), list(4, 5, 6, 7, 8)); + public void checkStability() { + class DummyAllSame implements Comparable { + @Override + public int compareTo(DummyAllSame o) { + return 0; // all are same + } + } + + final DummyAllSame a = new DummyAllSame(); + final DummyAllSame b = new DummyAllSame(); + final DummyAllSame c = new DummyAllSame(); + + final List list = Arrays.asList(a, b, c); + CollectionUtils.sort(list); + + assertSame(a, list.get(0)); + assertSame(b, list.get(1)); + assertSame(c, list.get(2)); + + assertEquals(3, list.size()); + } + + @Test + public void checkConstructor() { + try { + new CollectionUtils(); + } catch (final Exception ignored) { + fail(ignored); + } } }