379 |
|
*/ |
380 |
|
public void testIterator() { |
381 |
|
LinkedList q = populatedQueue(SIZE); |
382 |
– |
int i = 0; |
382 |
|
Iterator it = q.iterator(); |
383 |
< |
while (it.hasNext()) { |
383 |
> |
int i; |
384 |
> |
for (i = 0; it.hasNext(); i++) |
385 |
|
assertTrue(q.contains(it.next())); |
386 |
– |
++i; |
387 |
– |
} |
386 |
|
assertEquals(i, SIZE); |
387 |
+ |
assertIteratorExhausted(it); |
388 |
+ |
} |
389 |
+ |
|
390 |
+ |
/** |
391 |
+ |
* iterator of empty collection has no elements |
392 |
+ |
*/ |
393 |
+ |
public void testEmptyIterator() { |
394 |
+ |
assertIteratorExhausted(new LinkedList().iterator()); |
395 |
|
} |
396 |
|
|
397 |
|
/** |