ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/PriorityQueueTest.java
(Generate patch)

Comparing jsr166/src/test/tck/PriorityQueueTest.java (file contents):
Revision 1.16 by jsr166, Wed Aug 25 00:07:03 2010 UTC vs.
Revision 1.20 by jsr166, Thu Nov 18 20:21:53 2010 UTC

# Line 29 | Line 29 | public class PriorityQueueTest extends J
29       * Create a queue of given size containing consecutive
30       * Integers 0 ... n.
31       */
32 <    private PriorityQueue populatedQueue(int n) {
33 <        PriorityQueue q = new PriorityQueue(n);
32 >    private PriorityQueue<Integer> populatedQueue(int n) {
33 >        PriorityQueue<Integer> q = new PriorityQueue<Integer>(n);
34          assertTrue(q.isEmpty());
35          for (int i = n-1; i >= 0; i-=2)
36              assertTrue(q.offer(new Integer(i)));
# Line 213 | Line 213 | public class PriorityQueueTest extends J
213              shouldThrow();
214          } catch (NullPointerException success) {}
215      }
216 +
217      /**
218       * addAll of a collection with null elements throws NPE
219       */
# Line 224 | Line 225 | public class PriorityQueueTest extends J
225              shouldThrow();
226          } catch (NullPointerException success) {}
227      }
228 +
229      /**
230       * addAll of a collection with any null elements throws NPE after
231       * possibly adding some elements
# Line 314 | Line 316 | public class PriorityQueueTest extends J
316      public void testRemoveElement() {
317          PriorityQueue q = populatedQueue(SIZE);
318          for (int i = 1; i < SIZE; i+=2) {
319 <            assertTrue(q.remove(new Integer(i)));
319 >            assertTrue(q.contains(i));
320 >            assertTrue(q.remove(i));
321 >            assertFalse(q.contains(i));
322 >            assertTrue(q.contains(i-1));
323          }
324          for (int i = 0; i < SIZE; i+=2) {
325 <            assertTrue(q.remove(new Integer(i)));
326 <            assertFalse(q.remove(new Integer(i+1)));
325 >            assertTrue(q.contains(i));
326 >            assertTrue(q.remove(i));
327 >            assertFalse(q.contains(i));
328 >            assertFalse(q.remove(i+1));
329 >            assertFalse(q.contains(i+1));
330          }
331          assertTrue(q.isEmpty());
332      }
# Line 406 | Line 414 | public class PriorityQueueTest extends J
414          Object[] o = q.toArray();
415          Arrays.sort(o);
416          for (int i = 0; i < o.length; i++)
417 <            assertEquals(o[i], q.poll());
417 >            assertSame(o[i], q.poll());
418      }
419  
420      /**
421       * toArray(a) contains all elements
422       */
423      public void testToArray2() {
424 <        PriorityQueue q = populatedQueue(SIZE);
424 >        PriorityQueue<Integer> q = populatedQueue(SIZE);
425          Integer[] ints = new Integer[SIZE];
426 <        ints = (Integer[])q.toArray(ints);
426 >        Integer[] array = q.toArray(ints);
427 >        assertSame(ints, array);
428          Arrays.sort(ints);
429          for (int i = 0; i < ints.length; i++)
430 <            assertEquals(ints[i], q.poll());
430 >            assertSame(ints[i], q.poll());
431      }
432  
433      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines