478 |
|
*/ |
479 |
|
public void testIterator() { |
480 |
|
TreeSet q = populatedSet(SIZE); |
481 |
– |
int i = 0; |
481 |
|
Iterator it = q.iterator(); |
482 |
< |
while (it.hasNext()) { |
482 |
> |
int i; |
483 |
> |
for (i = 0; it.hasNext(); i++) |
484 |
|
assertTrue(q.contains(it.next())); |
485 |
– |
++i; |
486 |
– |
} |
485 |
|
assertEquals(i, SIZE); |
486 |
+ |
assertIteratorExhausted(it); |
487 |
|
} |
488 |
|
|
489 |
|
/** |
490 |
|
* iterator of empty set has no elements |
491 |
|
*/ |
492 |
|
public void testEmptyIterator() { |
493 |
< |
TreeSet q = new TreeSet(); |
495 |
< |
int i = 0; |
496 |
< |
Iterator it = q.iterator(); |
497 |
< |
while (it.hasNext()) { |
498 |
< |
assertTrue(q.contains(it.next())); |
499 |
< |
++i; |
500 |
< |
} |
501 |
< |
assertEquals(0, i); |
493 |
> |
assertIteratorExhausted(new TreeSet().iterator()); |
494 |
|
} |
495 |
|
|
496 |
|
/** |