test/java/util/Collection/ListDefaults.java

Print this page
rev 7302 : 8009736: Comparator API cleanup
Reviewed-by:
Contributed-by: henry.jen@oracle.com

*** 23,33 **** import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; - import java.util.Comparators; import java.util.List; import java.util.LinkedList; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; --- 23,32 ----
*** 335,361 **** } CollectionAsserts.assertContents(list, original); CollectionSupplier.shuffle(list); list.sort(null); ! CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder()); if (test.name.startsWith("reverse")) { Collections.reverse(list); } CollectionAsserts.assertContents(list, original); CollectionSupplier.shuffle(list); ! list.sort(Comparators.<Integer>naturalOrder()); ! CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder()); if (test.name.startsWith("reverse")) { Collections.reverse(list); } CollectionAsserts.assertContents(list, original); CollectionSupplier.shuffle(list); ! list.sort(Comparators.<Integer>reverseOrder()); ! CollectionAsserts.assertSorted(list, Comparators.<Integer>reverseOrder()); if (!test.name.startsWith("reverse")) { Collections.reverse(list); } CollectionAsserts.assertContents(list, original); --- 334,360 ---- } CollectionAsserts.assertContents(list, original); CollectionSupplier.shuffle(list); list.sort(null); ! CollectionAsserts.assertSorted(list, Comparator.<Integer>naturalOrder()); if (test.name.startsWith("reverse")) { Collections.reverse(list); } CollectionAsserts.assertContents(list, original); CollectionSupplier.shuffle(list); ! list.sort(Comparator.<Integer>naturalOrder()); ! CollectionAsserts.assertSorted(list, Comparator.<Integer>naturalOrder()); if (test.name.startsWith("reverse")) { Collections.reverse(list); } CollectionAsserts.assertContents(list, original); CollectionSupplier.shuffle(list); ! list.sort(Comparator.<Integer>reverseOrder()); ! CollectionAsserts.assertSorted(list, Comparator.<Integer>reverseOrder()); if (!test.name.startsWith("reverse")) { Collections.reverse(list); } CollectionAsserts.assertContents(list, original);
*** 388,399 **** if (original.size() > SUBLIST_SIZE) { final List<Integer> copy = new ArrayList<>(list); final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO); CollectionSupplier.shuffle(subList); ! subList.sort(Comparators.<Integer>naturalOrder()); ! CollectionAsserts.assertSorted(subList, Comparators.<Integer>naturalOrder()); // verify that elements [0, from) remain unmodified for (int i = 0; i < SUBLIST_FROM; i++) { assertTrue(list.get(i) == copy.get(i), "mismatch at index " + i); } --- 387,398 ---- if (original.size() > SUBLIST_SIZE) { final List<Integer> copy = new ArrayList<>(list); final List<Integer> subList = list.subList(SUBLIST_FROM, SUBLIST_TO); CollectionSupplier.shuffle(subList); ! subList.sort(Comparator.<Integer>naturalOrder()); ! CollectionAsserts.assertSorted(subList, Comparator.<Integer>naturalOrder()); // verify that elements [0, from) remain unmodified for (int i = 0; i < SUBLIST_FROM; i++) { assertTrue(list.get(i) == copy.get(i), "mismatch at index " + i); }
*** 410,421 **** trimmedSubList(list, new Callback() { @Override public void call(final List<Integer> list) { final List<Integer> copy = new ArrayList<>(list); CollectionSupplier.shuffle(list); ! list.sort(Comparators.<Integer>naturalOrder()); ! CollectionAsserts.assertSorted(list, Comparators.<Integer>naturalOrder()); } }); } } --- 409,420 ---- trimmedSubList(list, new Callback() { @Override public void call(final List<Integer> list) { final List<Integer> copy = new ArrayList<>(list); CollectionSupplier.shuffle(list); ! list.sort(Comparator.<Integer>naturalOrder()); ! CollectionAsserts.assertSorted(list, Comparator.<Integer>naturalOrder()); } }); } }