39 |
|
private TreeSet populatedSet(int n) { |
40 |
|
TreeSet q = new TreeSet(); |
41 |
|
assertTrue(q.isEmpty()); |
42 |
< |
for(int i = n-1; i >= 0; i-=2) |
42 |
> |
for (int i = n-1; i >= 0; i-=2) |
43 |
|
assertTrue(q.add(new Integer(i))); |
44 |
< |
for(int i = (n & 1); i < n; i+=2) |
44 |
> |
for (int i = (n & 1); i < n; i+=2) |
45 |
|
assertTrue(q.add(new Integer(i))); |
46 |
|
assertFalse(q.isEmpty()); |
47 |
|
assertEquals(n, q.size()); |
209 |
|
q.add(new Object()); |
210 |
|
shouldThrow(); |
211 |
|
} |
212 |
< |
catch(ClassCastException success) {} |
212 |
> |
catch (ClassCastException success) {} |
213 |
|
} |
214 |
|
|
215 |
|
/** |
467 |
|
TreeSet q = populatedSet(SIZE); |
468 |
|
Object[] o = q.toArray(); |
469 |
|
Arrays.sort(o); |
470 |
< |
for(int i = 0; i < o.length; i++) |
470 |
> |
for (int i = 0; i < o.length; i++) |
471 |
|
assertEquals(o[i], q.pollFirst()); |
472 |
|
} |
473 |
|
|
479 |
|
Integer[] ints = new Integer[SIZE]; |
480 |
|
ints = (Integer[])q.toArray(ints); |
481 |
|
Arrays.sort(ints); |
482 |
< |
for(int i = 0; i < ints.length; i++) |
482 |
> |
for (int i = 0; i < ints.length; i++) |
483 |
|
assertEquals(ints[i], q.pollFirst()); |
484 |
|
} |
485 |
|
|
490 |
|
TreeSet q = populatedSet(SIZE); |
491 |
|
int i = 0; |
492 |
|
Iterator it = q.iterator(); |
493 |
< |
while(it.hasNext()) { |
493 |
> |
while (it.hasNext()) { |
494 |
|
assertTrue(q.contains(it.next())); |
495 |
|
++i; |
496 |
|
} |
504 |
|
TreeSet q = new TreeSet(); |
505 |
|
int i = 0; |
506 |
|
Iterator it = q.iterator(); |
507 |
< |
while(it.hasNext()) { |
507 |
> |
while (it.hasNext()) { |
508 |
|
assertTrue(q.contains(it.next())); |
509 |
|
++i; |
510 |
|
} |
559 |
|
assertEquals(q.size(), r.size()); |
560 |
|
while (!q.isEmpty()) |
561 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
562 |
< |
} catch(Exception e){ |
562 |
> |
} catch (Exception e){ |
563 |
|
e.printStackTrace(); |
564 |
|
unexpectedException(); |
565 |
|
} |
713 |
|
NavigableSet<Integer> result = null; |
714 |
|
try { |
715 |
|
result = (NavigableSet<Integer>) cl.newInstance(); |
716 |
< |
} catch(Exception e) { |
716 |
> |
} catch (Exception e) { |
717 |
|
fail(); |
718 |
|
} |
719 |
|
assertEquals(result.size(), 0); |
738 |
|
} |
739 |
|
|
740 |
|
// Remove a bunch of entries with iterator |
741 |
< |
for(Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
741 |
> |
for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
742 |
|
if (rnd.nextBoolean()) { |
743 |
|
bs.clear(it.next()); |
744 |
|
it.remove(); |
763 |
|
} |
764 |
|
|
765 |
|
// Remove a bunch of entries with iterator |
766 |
< |
for(Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
766 |
> |
for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
767 |
|
if (rnd.nextBoolean()) { |
768 |
|
bs.clear(it.next()); |
769 |
|
it.remove(); |
779 |
|
try { |
780 |
|
set.add(element); |
781 |
|
fail(); |
782 |
< |
} catch(IllegalArgumentException e) { |
782 |
> |
} catch (IllegalArgumentException e) { |
783 |
|
// expected |
784 |
|
} |
785 |
|
} |
981 |
|
try { |
982 |
|
set.first(); |
983 |
|
fail(); |
984 |
< |
} catch(NoSuchElementException e) { |
984 |
> |
} catch (NoSuchElementException e) { |
985 |
|
// expected |
986 |
|
} |
987 |
|
try { |
988 |
|
set.last(); |
989 |
|
fail(); |
990 |
< |
} catch(NoSuchElementException e) { |
990 |
> |
} catch (NoSuchElementException e) { |
991 |
|
// expected |
992 |
|
} |
993 |
|
} |