--- jsr166/src/test/tck/PriorityQueueTest.java 2017/03/11 18:20:47 1.42 +++ jsr166/src/test/tck/PriorityQueueTest.java 2018/05/28 21:19:50 1.47 @@ -28,11 +28,22 @@ public class PriorityQueueTest extends J public boolean isConcurrent() { return false; } public boolean permitsNulls() { return false; } } - return newTestSuite(PriorityQueueTest.class, - CollectionTest.testSuite(new Implementation())); + class ComparatorImplementation implements CollectionImplementation { + public Class klazz() { return PriorityQueue.class; } + public Collection emptyCollection() { + return new PriorityQueue(new MyReverseComparator()); + } + public Object makeElement(int i) { return i; } + public boolean isConcurrent() { return false; } + public boolean permitsNulls() { return false; } + } + return newTestSuite( + PriorityQueueTest.class, + CollectionTest.testSuite(new Implementation()), + CollectionTest.testSuite(new ComparatorImplementation())); } - static class MyReverseComparator implements Comparator { + static class MyReverseComparator implements Comparator, java.io.Serializable { public int compare(Object x, Object y) { return ((Comparable)y).compareTo(x); } @@ -63,7 +74,7 @@ public class PriorityQueueTest extends J } /** - * Constructor throws IAE if capacity argument nonpositive + * Constructor throws IllegalArgumentException if capacity argument nonpositive */ public void testConstructor2() { try { @@ -425,10 +436,12 @@ public class PriorityQueueTest extends J */ public void testToArray() { PriorityQueue q = populatedQueue(SIZE); - Object[] o = q.toArray(); - Arrays.sort(o); - for (int i = 0; i < o.length; i++) - assertSame(o[i], q.poll()); + Object[] a = q.toArray(); + assertSame(Object[].class, a.getClass()); + Arrays.sort(a); + for (Object o : a) + assertSame(o, q.poll()); + assertTrue(q.isEmpty()); } /** @@ -440,8 +453,9 @@ public class PriorityQueueTest extends J Integer[] array = q.toArray(ints); assertSame(ints, array); Arrays.sort(ints); - for (int i = 0; i < ints.length; i++) - assertSame(ints[i], q.poll()); + for (Integer o : ints) + assertSame(o, q.poll()); + assertTrue(q.isEmpty()); } /** @@ -495,7 +509,7 @@ public class PriorityQueueTest extends J } /** - * A deserialized serialized queue has same elements + * A deserialized/reserialized queue has same elements */ public void testSerialization() throws Exception { Queue x = populatedQueue(SIZE);