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 |
|
/** |
730 |
|
// Add entries till we're back to original size |
731 |
|
while (set.size() < size) { |
732 |
|
int element = min + rnd.nextInt(rangeSize); |
733 |
< |
assertTrue(element >= min && element<= max); |
733 |
> |
assertTrue(element >= min && element <= max); |
734 |
|
put(set, element); |
735 |
|
} |
736 |
|
} |
755 |
|
// Add entries till we're back to original size |
756 |
|
while (set.size() < size) { |
757 |
|
int element = min - 5 + rnd.nextInt(rangeSize + 10); |
758 |
< |
if (element >= min && element<= max) { |
758 |
> |
if (element >= min && element <= max) { |
759 |
|
put(set, element); |
760 |
|
} else { |
761 |
|
try { |