115 |
|
* The comparator used in constructor is used |
116 |
|
*/ |
117 |
|
public void testConstructor7() { |
118 |
< |
try { |
119 |
< |
MyReverseComparator cmp = new MyReverseComparator(); |
120 |
< |
ConcurrentSkipListSet q = new ConcurrentSkipListSet(cmp); |
121 |
< |
assertEquals(cmp, q.comparator()); |
122 |
< |
Integer[] ints = new Integer[SIZE]; |
123 |
< |
for (int i = 0; i < SIZE; ++i) |
124 |
< |
ints[i] = new Integer(i); |
125 |
< |
q.addAll(Arrays.asList(ints)); |
126 |
< |
for (int i = SIZE-1; i >= 0; --i) |
127 |
< |
assertEquals(ints[i], q.pollFirst()); |
128 |
< |
} |
129 |
< |
finally {} |
118 |
> |
MyReverseComparator cmp = new MyReverseComparator(); |
119 |
> |
ConcurrentSkipListSet q = new ConcurrentSkipListSet(cmp); |
120 |
> |
assertEquals(cmp, q.comparator()); |
121 |
> |
Integer[] ints = new Integer[SIZE]; |
122 |
> |
for (int i = 0; i < SIZE; ++i) |
123 |
> |
ints[i] = new Integer(i); |
124 |
> |
q.addAll(Arrays.asList(ints)); |
125 |
> |
for (int i = SIZE-1; i >= 0; --i) |
126 |
> |
assertEquals(ints[i], q.pollFirst()); |
127 |
|
} |
128 |
|
|
129 |
|
/** |
237 |
|
* Set contains all elements of successful addAll |
238 |
|
*/ |
239 |
|
public void testAddAll5() { |
240 |
< |
try { |
241 |
< |
Integer[] empty = new Integer[0]; |
242 |
< |
Integer[] ints = new Integer[SIZE]; |
243 |
< |
for (int i = 0; i < SIZE; ++i) |
244 |
< |
ints[i] = new Integer(SIZE-1-i); |
245 |
< |
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
246 |
< |
assertFalse(q.addAll(Arrays.asList(empty))); |
247 |
< |
assertTrue(q.addAll(Arrays.asList(ints))); |
248 |
< |
for (int i = 0; i < SIZE; ++i) |
252 |
< |
assertEquals(new Integer(i), q.pollFirst()); |
253 |
< |
} |
254 |
< |
finally {} |
240 |
> |
Integer[] empty = new Integer[0]; |
241 |
> |
Integer[] ints = new Integer[SIZE]; |
242 |
> |
for (int i = 0; i < SIZE; ++i) |
243 |
> |
ints[i] = new Integer(SIZE-1-i); |
244 |
> |
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
245 |
> |
assertFalse(q.addAll(Arrays.asList(empty))); |
246 |
> |
assertTrue(q.addAll(Arrays.asList(ints))); |
247 |
> |
for (int i = 0; i < SIZE; ++i) |
248 |
> |
assertEquals(new Integer(i), q.pollFirst()); |
249 |
|
} |
250 |
|
|
251 |
|
/** |
664 |
|
/** |
665 |
|
* Subsets of subsets subdivide correctly |
666 |
|
*/ |
667 |
< |
public void testRecursiveSubSets() { |
667 |
> |
public void testRecursiveSubSets() throws Exception { |
668 |
|
int setSize = 1000; |
669 |
|
Class cl = ConcurrentSkipListSet.class; |
670 |
|
|
683 |
|
0, setSize - 1, true); |
684 |
|
} |
685 |
|
|
686 |
< |
static NavigableSet<Integer> newSet(Class cl) { |
687 |
< |
NavigableSet<Integer> result = null; |
694 |
< |
try { |
695 |
< |
result = (NavigableSet<Integer>) cl.newInstance(); |
696 |
< |
} catch (Exception e) { |
697 |
< |
fail(); |
698 |
< |
} |
686 |
> |
static NavigableSet<Integer> newSet(Class cl) throws Exception { |
687 |
> |
NavigableSet<Integer> result = (NavigableSet<Integer>) cl.newInstance(); |
688 |
|
assertEquals(result.size(), 0); |
689 |
|
assertFalse(result.iterator().hasNext()); |
690 |
|
return result; |
747 |
|
} else { |
748 |
|
try { |
749 |
|
set.add(element); |
750 |
< |
fail(); |
751 |
< |
} catch (IllegalArgumentException e) { |
763 |
< |
// expected |
764 |
< |
} |
750 |
> |
shouldThrow(); |
751 |
> |
} catch (IllegalArgumentException success) {} |
752 |
|
} |
753 |
|
} |
754 |
|
} |
947 |
|
assertEq(rs.last(), -1); |
948 |
|
try { |
949 |
|
set.first(); |
950 |
< |
fail(); |
951 |
< |
} catch (NoSuchElementException e) { |
965 |
< |
// expected |
966 |
< |
} |
950 |
> |
shouldThrow(); |
951 |
> |
} catch (NoSuchElementException success) {} |
952 |
|
try { |
953 |
|
set.last(); |
954 |
< |
fail(); |
955 |
< |
} catch (NoSuchElementException e) { |
971 |
< |
// expected |
972 |
< |
} |
954 |
> |
shouldThrow(); |
955 |
> |
} catch (NoSuchElementException success) {} |
956 |
|
} |
957 |
|
} |
958 |
|
|