17 |
|
|
18 |
|
public class TreeSubSetTest extends JSR166TestCase { |
19 |
|
public static void main(String[] args) { |
20 |
< |
junit.textui.TestRunner.run(suite()); |
20 |
> |
main(suite(), args); |
21 |
|
} |
22 |
|
public static Test suite() { |
23 |
|
return new TestSuite(TreeSubSetTest.class); |
132 |
|
* add(null) throws NPE |
133 |
|
*/ |
134 |
|
public void testAddNull() { |
135 |
+ |
NavigableSet q = set0(); |
136 |
|
try { |
136 |
– |
NavigableSet q = set0(); |
137 |
|
q.add(null); |
138 |
|
shouldThrow(); |
139 |
|
} catch (NullPointerException success) {} |
160 |
|
* Add of non-Comparable throws CCE |
161 |
|
*/ |
162 |
|
public void testAddNonComparable() { |
163 |
+ |
NavigableSet q = set0(); |
164 |
|
try { |
164 |
– |
NavigableSet q = set0(); |
165 |
– |
q.add(new Object()); |
165 |
|
q.add(new Object()); |
166 |
|
q.add(new Object()); |
167 |
|
shouldThrow(); |
172 |
|
* addAll(null) throws NPE |
173 |
|
*/ |
174 |
|
public void testAddAll1() { |
175 |
+ |
NavigableSet q = set0(); |
176 |
|
try { |
177 |
– |
NavigableSet q = set0(); |
177 |
|
q.addAll(null); |
178 |
|
shouldThrow(); |
179 |
|
} catch (NullPointerException success) {} |
183 |
|
* addAll of a collection with null elements throws NPE |
184 |
|
*/ |
185 |
|
public void testAddAll2() { |
186 |
+ |
NavigableSet q = set0(); |
187 |
+ |
Integer[] ints = new Integer[SIZE]; |
188 |
|
try { |
188 |
– |
NavigableSet q = set0(); |
189 |
– |
Integer[] ints = new Integer[SIZE]; |
189 |
|
q.addAll(Arrays.asList(ints)); |
190 |
|
shouldThrow(); |
191 |
|
} catch (NullPointerException success) {} |
196 |
|
* possibly adding some elements |
197 |
|
*/ |
198 |
|
public void testAddAll3() { |
199 |
+ |
NavigableSet q = set0(); |
200 |
+ |
Integer[] ints = new Integer[SIZE]; |
201 |
+ |
for (int i = 0; i < SIZE-1; ++i) |
202 |
+ |
ints[i] = new Integer(i+SIZE); |
203 |
|
try { |
201 |
– |
NavigableSet q = set0(); |
202 |
– |
Integer[] ints = new Integer[SIZE]; |
203 |
– |
for (int i = 0; i < SIZE-1; ++i) |
204 |
– |
ints[i] = new Integer(i+SIZE); |
204 |
|
q.addAll(Arrays.asList(ints)); |
205 |
|
shouldThrow(); |
206 |
|
} catch (NullPointerException success) {} |
322 |
|
assertTrue(q.removeAll(p)); |
323 |
|
assertEquals(SIZE-i, q.size()); |
324 |
|
for (int j = 0; j < i; ++j) { |
325 |
< |
Integer I = (Integer)(p.pollFirst()); |
326 |
< |
assertFalse(q.contains(I)); |
325 |
> |
Integer x = (Integer)(p.pollFirst()); |
326 |
> |
assertFalse(q.contains(x)); |
327 |
|
} |
328 |
|
} |
329 |
|
} |
427 |
|
*/ |
428 |
|
public void testIterator() { |
429 |
|
NavigableSet q = populatedSet(SIZE); |
431 |
– |
int i = 0; |
430 |
|
Iterator it = q.iterator(); |
431 |
< |
while (it.hasNext()) { |
431 |
> |
int i; |
432 |
> |
for (i = 0; it.hasNext(); i++) |
433 |
|
assertTrue(q.contains(it.next())); |
435 |
– |
++i; |
436 |
– |
} |
434 |
|
assertEquals(i, SIZE); |
435 |
+ |
assertIteratorExhausted(it); |
436 |
|
} |
437 |
|
|
438 |
|
/** |
439 |
|
* iterator of empty set has no elements |
440 |
|
*/ |
441 |
|
public void testEmptyIterator() { |
442 |
< |
NavigableSet q = set0(); |
445 |
< |
int i = 0; |
446 |
< |
Iterator it = q.iterator(); |
447 |
< |
while (it.hasNext()) { |
448 |
< |
assertTrue(q.contains(it.next())); |
449 |
< |
++i; |
450 |
< |
} |
451 |
< |
assertEquals(0, i); |
442 |
> |
assertIteratorExhausted(set0().iterator()); |
443 |
|
} |
444 |
|
|
445 |
|
/** |
645 |
|
* Add of non-Comparable throws CCE |
646 |
|
*/ |
647 |
|
public void testDescendingAddNonComparable() { |
648 |
+ |
NavigableSet q = dset0(); |
649 |
|
try { |
658 |
– |
NavigableSet q = dset0(); |
659 |
– |
q.add(new Object()); |
650 |
|
q.add(new Object()); |
651 |
|
q.add(new Object()); |
652 |
|
shouldThrow(); |
657 |
|
* addAll(null) throws NPE |
658 |
|
*/ |
659 |
|
public void testDescendingAddAll1() { |
660 |
+ |
NavigableSet q = dset0(); |
661 |
|
try { |
671 |
– |
NavigableSet q = dset0(); |
662 |
|
q.addAll(null); |
663 |
|
shouldThrow(); |
664 |
|
} catch (NullPointerException success) {} |
668 |
|
* addAll of a collection with null elements throws NPE |
669 |
|
*/ |
670 |
|
public void testDescendingAddAll2() { |
671 |
+ |
NavigableSet q = dset0(); |
672 |
+ |
Integer[] ints = new Integer[SIZE]; |
673 |
|
try { |
682 |
– |
NavigableSet q = dset0(); |
683 |
– |
Integer[] ints = new Integer[SIZE]; |
674 |
|
q.addAll(Arrays.asList(ints)); |
675 |
|
shouldThrow(); |
676 |
|
} catch (NullPointerException success) {} |
681 |
|
* possibly adding some elements |
682 |
|
*/ |
683 |
|
public void testDescendingAddAll3() { |
684 |
+ |
NavigableSet q = dset0(); |
685 |
+ |
Integer[] ints = new Integer[SIZE]; |
686 |
+ |
for (int i = 0; i < SIZE-1; ++i) |
687 |
+ |
ints[i] = new Integer(i+SIZE); |
688 |
|
try { |
695 |
– |
NavigableSet q = dset0(); |
696 |
– |
Integer[] ints = new Integer[SIZE]; |
697 |
– |
for (int i = 0; i < SIZE-1; ++i) |
698 |
– |
ints[i] = new Integer(i+SIZE); |
689 |
|
q.addAll(Arrays.asList(ints)); |
690 |
|
shouldThrow(); |
691 |
|
} catch (NullPointerException success) {} |
801 |
|
assertTrue(q.removeAll(p)); |
802 |
|
assertEquals(SIZE-i, q.size()); |
803 |
|
for (int j = 0; j < i; ++j) { |
804 |
< |
Integer I = (Integer)(p.pollFirst()); |
805 |
< |
assertFalse(q.contains(I)); |
804 |
> |
Integer x = (Integer)(p.pollFirst()); |
805 |
> |
assertFalse(q.contains(x)); |
806 |
|
} |
807 |
|
} |
808 |
|
} |