11 |
|
|
12 |
|
public class TreeSetTest extends JSR166TestCase { |
13 |
|
public static void main(String[] args) { |
14 |
< |
junit.textui.TestRunner.run (suite()); |
14 |
> |
junit.textui.TestRunner.run(suite()); |
15 |
|
} |
16 |
|
public static Test suite() { |
17 |
|
return new TestSuite(TreeSetTest.class); |
208 |
|
shouldThrow(); |
209 |
|
} catch (NullPointerException success) {} |
210 |
|
} |
211 |
+ |
|
212 |
|
/** |
213 |
|
* addAll of a collection with null elements throws NPE |
214 |
|
*/ |
220 |
|
shouldThrow(); |
221 |
|
} catch (NullPointerException success) {} |
222 |
|
} |
223 |
+ |
|
224 |
|
/** |
225 |
|
* addAll of a collection with any null elements throws NPE after |
226 |
|
* possibly adding some elements |
439 |
|
} |
440 |
|
|
441 |
|
/** |
442 |
< |
* toArray contains all elements |
442 |
> |
* toArray contains all elements in sorted order |
443 |
|
*/ |
444 |
|
public void testToArray() { |
445 |
|
TreeSet q = populatedSet(SIZE); |
446 |
|
Object[] o = q.toArray(); |
445 |
– |
Arrays.sort(o); |
447 |
|
for (int i = 0; i < o.length; i++) |
448 |
< |
assertEquals(o[i], q.pollFirst()); |
448 |
> |
assertSame(o[i], q.pollFirst()); |
449 |
|
} |
450 |
|
|
451 |
|
/** |
452 |
< |
* toArray(a) contains all elements |
452 |
> |
* toArray(a) contains all elements in sorted order |
453 |
|
*/ |
454 |
|
public void testToArray2() { |
455 |
|
TreeSet q = populatedSet(SIZE); |
456 |
|
Integer[] ints = new Integer[SIZE]; |
457 |
< |
ints = (Integer[])q.toArray(ints); |
457 |
< |
Arrays.sort(ints); |
457 |
> |
assertSame(ints, q.toArray(ints)); |
458 |
|
for (int i = 0; i < ints.length; i++) |
459 |
< |
assertEquals(ints[i], q.pollFirst()); |
459 |
> |
assertSame(ints[i], q.pollFirst()); |
460 |
|
} |
461 |
|
|
462 |
|
/** |
490 |
|
/** |
491 |
|
* iterator.remove removes current element |
492 |
|
*/ |
493 |
< |
public void testIteratorRemove () { |
493 |
> |
public void testIteratorRemove() { |
494 |
|
final TreeSet q = new TreeSet(); |
495 |
|
q.add(new Integer(2)); |
496 |
|
q.add(new Integer(1)); |
662 |
|
* Subsets of subsets subdivide correctly |
663 |
|
*/ |
664 |
|
public void testRecursiveSubSets() throws Exception { |
665 |
< |
int setSize = 1000; |
665 |
> |
int setSize = expensiveTests ? 1000 : 100; |
666 |
|
Class cl = TreeSet.class; |
667 |
|
|
668 |
|
NavigableSet<Integer> set = newSet(cl); |
878 |
|
// BitSet should support this! Test would run much faster |
879 |
|
while (element >= min) { |
880 |
|
if (bs.get(element)) |
881 |
< |
return(element); |
881 |
> |
return element; |
882 |
|
element--; |
883 |
|
} |
884 |
|
return -1; |