11 |
|
|
12 |
|
public class ConcurrentSkipListSetTest 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(ConcurrentSkipListSetTest.class); |
18 |
|
} |
19 |
|
|
20 |
< |
static class MyReverseComparator implements Comparator { |
20 |
> |
static class MyReverseComparator implements Comparator { |
21 |
|
public int compare(Object x, Object y) { |
22 |
|
int i = ((Integer)x).intValue(); |
23 |
|
int j = ((Integer)y).intValue(); |
57 |
|
assertEquals(5, q.size()); |
58 |
|
return q; |
59 |
|
} |
60 |
< |
|
60 |
> |
|
61 |
|
/** |
62 |
|
* A new set has unbounded capacity |
63 |
|
*/ |
172 |
|
ConcurrentSkipListSet q = new ConcurrentSkipListSet(); |
173 |
|
q.add(null); |
174 |
|
shouldThrow(); |
175 |
< |
} catch (NullPointerException success) { } |
175 |
> |
} catch (NullPointerException success) { } |
176 |
|
} |
177 |
|
|
178 |
|
/** |
301 |
|
} |
302 |
|
assertTrue(q.isEmpty()); |
303 |
|
} |
304 |
< |
|
304 |
> |
|
305 |
|
/** |
306 |
|
* contains(x) reports true when elements added but not yet removed |
307 |
|
*/ |
377 |
|
} |
378 |
|
} |
379 |
|
|
380 |
< |
|
380 |
> |
|
381 |
|
|
382 |
|
/** |
383 |
|
* lower returns preceding element |
477 |
|
for(int i = 0; i < ints.length; i++) |
478 |
|
assertEquals(ints[i], q.pollFirst()); |
479 |
|
} |
480 |
< |
|
480 |
> |
|
481 |
|
/** |
482 |
|
* iterator iterates through all elements |
483 |
|
*/ |
535 |
|
for (int i = 0; i < SIZE; ++i) { |
536 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
537 |
|
} |
538 |
< |
} |
538 |
> |
} |
539 |
|
|
540 |
|
/** |
541 |
< |
* A deserialized serialized set has same elements |
541 |
> |
* A deserialized serialized set has same elements |
542 |
|
*/ |
543 |
|
public void testSerialization() { |
544 |
|
ConcurrentSkipListSet q = populatedSet(SIZE); |
552 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
553 |
|
ConcurrentSkipListSet r = (ConcurrentSkipListSet)in.readObject(); |
554 |
|
assertEquals(q.size(), r.size()); |
555 |
< |
while (!q.isEmpty()) |
555 |
> |
while (!q.isEmpty()) |
556 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
557 |
|
} catch(Exception e){ |
558 |
|
e.printStackTrace(); |
700 |
|
check(set, 0, setSize - 1, true); |
701 |
|
check(set.descendingSet(), 0, setSize - 1, false); |
702 |
|
|
703 |
< |
bashSubSet(set.navigableSubSet(0, true, setSize, false), |
703 |
> |
bashSubSet(set.subSet(0, true, setSize, false), |
704 |
|
0, setSize - 1, true); |
705 |
|
} |
706 |
|
|
807 |
|
|
808 |
|
// headSet - pick direction and endpoint inclusion randomly |
809 |
|
boolean incl = rnd.nextBoolean(); |
810 |
< |
NavigableSet<Integer> hm = set.navigableHeadSet(midPoint, incl); |
810 |
> |
NavigableSet<Integer> hm = set.headSet(midPoint, incl); |
811 |
|
if (ascending) { |
812 |
|
if (rnd.nextBoolean()) |
813 |
|
bashSubSet(hm, min, midPoint - (incl ? 0 : 1), true); |
824 |
|
|
825 |
|
// tailSet - pick direction and endpoint inclusion randomly |
826 |
|
incl = rnd.nextBoolean(); |
827 |
< |
NavigableSet<Integer> tm = set.navigableTailSet(midPoint,incl); |
827 |
> |
NavigableSet<Integer> tm = set.tailSet(midPoint,incl); |
828 |
|
if (ascending) { |
829 |
|
if (rnd.nextBoolean()) |
830 |
|
bashSubSet(tm, midPoint + (incl ? 0 : 1), max, true); |
849 |
|
boolean lowIncl = rnd.nextBoolean(); |
850 |
|
boolean highIncl = rnd.nextBoolean(); |
851 |
|
if (ascending) { |
852 |
< |
NavigableSet<Integer> sm = set.navigableSubSet( |
852 |
> |
NavigableSet<Integer> sm = set.subSet( |
853 |
|
endpoints[0], lowIncl, endpoints[1], highIncl); |
854 |
|
if (rnd.nextBoolean()) |
855 |
|
bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1), |
858 |
|
bashSubSet(sm.descendingSet(), endpoints[0] + (lowIncl ? 0 : 1), |
859 |
|
endpoints[1] - (highIncl ? 0 : 1), false); |
860 |
|
} else { |
861 |
< |
NavigableSet<Integer> sm = set.navigableSubSet( |
861 |
> |
NavigableSet<Integer> sm = set.subSet( |
862 |
|
endpoints[1], highIncl, endpoints[0], lowIncl); |
863 |
|
if (rnd.nextBoolean()) |
864 |
|
bashSubSet(sm, endpoints[0] + (lowIncl ? 0 : 1), |