441 |
|
*/ |
442 |
|
public void testIterator() { |
443 |
|
PriorityQueue q = populatedQueue(SIZE); |
444 |
– |
int i = 0; |
444 |
|
Iterator it = q.iterator(); |
445 |
< |
while (it.hasNext()) { |
445 |
> |
int i; |
446 |
> |
for (i = 0; it.hasNext(); i++) |
447 |
|
assertTrue(q.contains(it.next())); |
448 |
– |
++i; |
449 |
– |
} |
448 |
|
assertEquals(i, SIZE); |
449 |
+ |
assertIteratorExhausted(it); |
450 |
+ |
} |
451 |
+ |
|
452 |
+ |
/** |
453 |
+ |
* iterator of empty collection has no elements |
454 |
+ |
*/ |
455 |
+ |
public void testEmptyIterator() { |
456 |
+ |
assertIteratorExhausted(new PriorityQueue().iterator()); |
457 |
|
} |
458 |
|
|
459 |
|
/** |