34 |
|
private ConcurrentSkipListSet populatedSet(int n) { |
35 |
|
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
36 |
|
assertTrue(q.isEmpty()); |
37 |
< |
for(int i = n-1; i >= 0; i-=2) |
37 |
> |
for (int i = n-1; i >= 0; i-=2) |
38 |
|
assertTrue(q.add(new Integer(i))); |
39 |
< |
for(int i = (n & 1); i < n; i+=2) |
39 |
> |
for (int i = (n & 1); i < n; i+=2) |
40 |
|
assertTrue(q.add(new Integer(i))); |
41 |
|
assertFalse(q.isEmpty()); |
42 |
|
assertEquals(n, q.size()); |
204 |
|
q.add(new Object()); |
205 |
|
shouldThrow(); |
206 |
|
} |
207 |
< |
catch(ClassCastException success) {} |
207 |
> |
catch (ClassCastException success) {} |
208 |
|
} |
209 |
|
|
210 |
|
/** |
462 |
|
ConcurrentSkipListSet q = populatedSet(SIZE); |
463 |
|
Object[] o = q.toArray(); |
464 |
|
Arrays.sort(o); |
465 |
< |
for(int i = 0; i < o.length; i++) |
465 |
> |
for (int i = 0; i < o.length; i++) |
466 |
|
assertEquals(o[i], q.pollFirst()); |
467 |
|
} |
468 |
|
|
474 |
|
Integer[] ints = new Integer[SIZE]; |
475 |
|
ints = (Integer[])q.toArray(ints); |
476 |
|
Arrays.sort(ints); |
477 |
< |
for(int i = 0; i < ints.length; i++) |
477 |
> |
for (int i = 0; i < ints.length; i++) |
478 |
|
assertEquals(ints[i], q.pollFirst()); |
479 |
|
} |
480 |
|
|
485 |
|
ConcurrentSkipListSet q = populatedSet(SIZE); |
486 |
|
int i = 0; |
487 |
|
Iterator it = q.iterator(); |
488 |
< |
while(it.hasNext()) { |
488 |
> |
while (it.hasNext()) { |
489 |
|
assertTrue(q.contains(it.next())); |
490 |
|
++i; |
491 |
|
} |
499 |
|
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
500 |
|
int i = 0; |
501 |
|
Iterator it = q.iterator(); |
502 |
< |
while(it.hasNext()) { |
502 |
> |
while (it.hasNext()) { |
503 |
|
assertTrue(q.contains(it.next())); |
504 |
|
++i; |
505 |
|
} |
554 |
|
assertEquals(q.size(), r.size()); |
555 |
|
while (!q.isEmpty()) |
556 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
557 |
< |
} catch(Exception e){ |
557 |
> |
} catch (Exception e){ |
558 |
|
e.printStackTrace(); |
559 |
|
unexpectedException(); |
560 |
|
} |
708 |
|
NavigableSet<Integer> result = null; |
709 |
|
try { |
710 |
|
result = (NavigableSet<Integer>) cl.newInstance(); |
711 |
< |
} catch(Exception e) { |
711 |
> |
} catch (Exception e) { |
712 |
|
fail(); |
713 |
|
} |
714 |
|
assertEquals(result.size(), 0); |
733 |
|
} |
734 |
|
|
735 |
|
// Remove a bunch of entries with iterator |
736 |
< |
for(Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
736 |
> |
for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
737 |
|
if (rnd.nextBoolean()) { |
738 |
|
bs.clear(it.next()); |
739 |
|
it.remove(); |
758 |
|
} |
759 |
|
|
760 |
|
// Remove a bunch of entries with iterator |
761 |
< |
for(Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
761 |
> |
for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) { |
762 |
|
if (rnd.nextBoolean()) { |
763 |
|
bs.clear(it.next()); |
764 |
|
it.remove(); |
774 |
|
try { |
775 |
|
set.add(element); |
776 |
|
fail(); |
777 |
< |
} catch(IllegalArgumentException e) { |
777 |
> |
} catch (IllegalArgumentException e) { |
778 |
|
// expected |
779 |
|
} |
780 |
|
} |
976 |
|
try { |
977 |
|
set.first(); |
978 |
|
fail(); |
979 |
< |
} catch(NoSuchElementException e) { |
979 |
> |
} catch (NoSuchElementException e) { |
980 |
|
// expected |
981 |
|
} |
982 |
|
try { |
983 |
|
set.last(); |
984 |
|
fail(); |
985 |
< |
} catch(NoSuchElementException e) { |
985 |
> |
} catch (NoSuchElementException e) { |
986 |
|
// expected |
987 |
|
} |
988 |
|
} |