33 |
|
|
34 |
|
/** |
35 |
|
* Returns a new queue of given size containing consecutive |
36 |
< |
* Integers 0 ... n. |
36 |
> |
* Integers 0 ... n - 1. |
37 |
|
*/ |
38 |
|
private PriorityQueue<Integer> populatedQueue(int n) { |
39 |
|
PriorityQueue<Integer> q = new PriorityQueue<Integer>(n); |
44 |
|
assertTrue(q.offer(new Integer(i))); |
45 |
|
assertFalse(q.isEmpty()); |
46 |
|
assertEquals(n, q.size()); |
47 |
+ |
assertEquals((Integer) 0, q.peek()); |
48 |
|
return q; |
49 |
|
} |
50 |
|
|
192 |
|
PriorityQueue q = new PriorityQueue(1); |
193 |
|
try { |
194 |
|
q.offer(new Object()); |
194 |
– |
q.offer(new Object()); |
195 |
|
shouldThrow(); |
196 |
< |
} catch (ClassCastException success) {} |
196 |
> |
} catch (ClassCastException success) { |
197 |
> |
assertTrue(q.isEmpty()); |
198 |
> |
assertEquals(0, q.size()); |
199 |
> |
assertNull(q.poll()); |
200 |
> |
} |
201 |
|
} |
202 |
|
|
203 |
|
/** |