16 |
|
|
17 |
|
public class ConcurrentSkipListSubSetTest extends JSR166TestCase { |
18 |
|
public static void main(String[] args) { |
19 |
< |
junit.textui.TestRunner.run(suite()); |
19 |
> |
main(suite(), args); |
20 |
|
} |
21 |
|
public static Test suite() { |
22 |
|
return new TestSuite(ConcurrentSkipListSubSetTest.class); |
135 |
|
* add(null) throws NPE |
136 |
|
*/ |
137 |
|
public void testAddNull() { |
138 |
+ |
NavigableSet q = set0(); |
139 |
|
try { |
139 |
– |
NavigableSet q = set0(); |
140 |
|
q.add(null); |
141 |
|
shouldThrow(); |
142 |
|
} catch (NullPointerException success) {} |
163 |
|
* Add of non-Comparable throws CCE |
164 |
|
*/ |
165 |
|
public void testAddNonComparable() { |
166 |
+ |
NavigableSet q = set0(); |
167 |
|
try { |
167 |
– |
NavigableSet q = set0(); |
168 |
– |
q.add(new Object()); |
168 |
|
q.add(new Object()); |
169 |
|
q.add(new Object()); |
170 |
|
shouldThrow(); |
175 |
|
* addAll(null) throws NPE |
176 |
|
*/ |
177 |
|
public void testAddAll1() { |
178 |
+ |
NavigableSet q = set0(); |
179 |
|
try { |
180 |
– |
NavigableSet q = set0(); |
180 |
|
q.addAll(null); |
181 |
|
shouldThrow(); |
182 |
|
} catch (NullPointerException success) {} |
186 |
|
* addAll of a collection with null elements throws NPE |
187 |
|
*/ |
188 |
|
public void testAddAll2() { |
189 |
+ |
NavigableSet q = set0(); |
190 |
+ |
Integer[] ints = new Integer[SIZE]; |
191 |
|
try { |
191 |
– |
NavigableSet q = set0(); |
192 |
– |
Integer[] ints = new Integer[SIZE]; |
192 |
|
q.addAll(Arrays.asList(ints)); |
193 |
|
shouldThrow(); |
194 |
|
} catch (NullPointerException success) {} |
199 |
|
* possibly adding some elements |
200 |
|
*/ |
201 |
|
public void testAddAll3() { |
202 |
+ |
NavigableSet q = set0(); |
203 |
+ |
Integer[] ints = new Integer[SIZE]; |
204 |
+ |
for (int i = 0; i < SIZE-1; ++i) |
205 |
+ |
ints[i] = new Integer(i+SIZE); |
206 |
|
try { |
204 |
– |
NavigableSet q = set0(); |
205 |
– |
Integer[] ints = new Integer[SIZE]; |
206 |
– |
for (int i = 0; i < SIZE-1; ++i) |
207 |
– |
ints[i] = new Integer(i+SIZE); |
207 |
|
q.addAll(Arrays.asList(ints)); |
208 |
|
shouldThrow(); |
209 |
|
} catch (NullPointerException success) {} |
430 |
|
*/ |
431 |
|
public void testIterator() { |
432 |
|
NavigableSet q = populatedSet(SIZE); |
434 |
– |
int i = 0; |
433 |
|
Iterator it = q.iterator(); |
434 |
< |
while (it.hasNext()) { |
434 |
> |
int i; |
435 |
> |
for (i = 0; it.hasNext(); i++) |
436 |
|
assertTrue(q.contains(it.next())); |
438 |
– |
++i; |
439 |
– |
} |
437 |
|
assertEquals(i, SIZE); |
438 |
+ |
assertIteratorExhausted(it); |
439 |
|
} |
440 |
|
|
441 |
|
/** |
442 |
|
* iterator of empty set has no elements |
443 |
|
*/ |
444 |
|
public void testEmptyIterator() { |
445 |
< |
NavigableSet q = set0(); |
448 |
< |
int i = 0; |
449 |
< |
Iterator it = q.iterator(); |
450 |
< |
while (it.hasNext()) { |
451 |
< |
assertTrue(q.contains(it.next())); |
452 |
< |
++i; |
453 |
< |
} |
454 |
< |
assertEquals(0, i); |
445 |
> |
assertIteratorExhausted(set0().iterator()); |
446 |
|
} |
447 |
|
|
448 |
|
/** |
631 |
|
* add(null) throws NPE |
632 |
|
*/ |
633 |
|
public void testDescendingAddNull() { |
634 |
+ |
NavigableSet q = dset0(); |
635 |
|
try { |
644 |
– |
NavigableSet q = dset0(); |
636 |
|
q.add(null); |
637 |
|
shouldThrow(); |
638 |
|
} catch (NullPointerException success) {} |
659 |
|
* Add of non-Comparable throws CCE |
660 |
|
*/ |
661 |
|
public void testDescendingAddNonComparable() { |
662 |
+ |
NavigableSet q = dset0(); |
663 |
|
try { |
672 |
– |
NavigableSet q = dset0(); |
673 |
– |
q.add(new Object()); |
664 |
|
q.add(new Object()); |
665 |
|
q.add(new Object()); |
666 |
|
shouldThrow(); |
671 |
|
* addAll(null) throws NPE |
672 |
|
*/ |
673 |
|
public void testDescendingAddAll1() { |
674 |
+ |
NavigableSet q = dset0(); |
675 |
|
try { |
685 |
– |
NavigableSet q = dset0(); |
676 |
|
q.addAll(null); |
677 |
|
shouldThrow(); |
678 |
|
} catch (NullPointerException success) {} |
682 |
|
* addAll of a collection with null elements throws NPE |
683 |
|
*/ |
684 |
|
public void testDescendingAddAll2() { |
685 |
+ |
NavigableSet q = dset0(); |
686 |
+ |
Integer[] ints = new Integer[SIZE]; |
687 |
|
try { |
696 |
– |
NavigableSet q = dset0(); |
697 |
– |
Integer[] ints = new Integer[SIZE]; |
688 |
|
q.addAll(Arrays.asList(ints)); |
689 |
|
shouldThrow(); |
690 |
|
} catch (NullPointerException success) {} |
695 |
|
* possibly adding some elements |
696 |
|
*/ |
697 |
|
public void testDescendingAddAll3() { |
698 |
+ |
NavigableSet q = dset0(); |
699 |
+ |
Integer[] ints = new Integer[SIZE]; |
700 |
+ |
for (int i = 0; i < SIZE-1; ++i) |
701 |
+ |
ints[i] = new Integer(i+SIZE); |
702 |
|
try { |
709 |
– |
NavigableSet q = dset0(); |
710 |
– |
Integer[] ints = new Integer[SIZE]; |
711 |
– |
for (int i = 0; i < SIZE-1; ++i) |
712 |
– |
ints[i] = new Integer(i+SIZE); |
703 |
|
q.addAll(Arrays.asList(ints)); |
704 |
|
shouldThrow(); |
705 |
|
} catch (NullPointerException success) {} |