--- jsr166/src/test/tck/PriorityQueueTest.java 2010/08/25 00:07:03 1.16 +++ jsr166/src/test/tck/PriorityQueueTest.java 2011/03/15 19:47:07 1.21 @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ * Other contributors include Andrew Wright, Jeffrey Hayes, * Pat Fisher, Mike Judd. */ @@ -29,8 +29,8 @@ public class PriorityQueueTest extends J * Create a queue of given size containing consecutive * Integers 0 ... n. */ - private PriorityQueue populatedQueue(int n) { - PriorityQueue q = new PriorityQueue(n); + private PriorityQueue populatedQueue(int n) { + PriorityQueue q = new PriorityQueue(n); assertTrue(q.isEmpty()); for (int i = n-1; i >= 0; i-=2) assertTrue(q.offer(new Integer(i))); @@ -213,6 +213,7 @@ public class PriorityQueueTest extends J shouldThrow(); } catch (NullPointerException success) {} } + /** * addAll of a collection with null elements throws NPE */ @@ -224,6 +225,7 @@ public class PriorityQueueTest extends J shouldThrow(); } catch (NullPointerException success) {} } + /** * addAll of a collection with any null elements throws NPE after * possibly adding some elements @@ -314,11 +316,17 @@ public class PriorityQueueTest extends J public void testRemoveElement() { PriorityQueue q = populatedQueue(SIZE); for (int i = 1; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); + assertTrue(q.contains(i)); + assertTrue(q.remove(i)); + assertFalse(q.contains(i)); + assertTrue(q.contains(i-1)); } for (int i = 0; i < SIZE; i+=2) { - assertTrue(q.remove(new Integer(i))); - assertFalse(q.remove(new Integer(i+1))); + assertTrue(q.contains(i)); + assertTrue(q.remove(i)); + assertFalse(q.contains(i)); + assertFalse(q.remove(i+1)); + assertFalse(q.contains(i+1)); } assertTrue(q.isEmpty()); } @@ -406,19 +414,20 @@ public class PriorityQueueTest extends J Object[] o = q.toArray(); Arrays.sort(o); for (int i = 0; i < o.length; i++) - assertEquals(o[i], q.poll()); + assertSame(o[i], q.poll()); } /** * toArray(a) contains all elements */ public void testToArray2() { - PriorityQueue q = populatedQueue(SIZE); + PriorityQueue q = populatedQueue(SIZE); Integer[] ints = new Integer[SIZE]; - ints = (Integer[])q.toArray(ints); + Integer[] array = q.toArray(ints); + assertSame(ints, array); Arrays.sort(ints); for (int i = 0; i < ints.length; i++) - assertEquals(ints[i], q.poll()); + assertSame(ints[i], q.poll()); } /**