11 |
|
|
12 |
|
public class ConcurrentSkipListSubSetTest 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(ConcurrentSkipListSubSetTest.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(); |
81 |
|
return s; |
82 |
|
} |
83 |
|
|
84 |
< |
private static NavigableSet set0() { |
84 |
> |
private static NavigableSet set0() { |
85 |
|
ConcurrentSkipListSet set = new ConcurrentSkipListSet(); |
86 |
|
assertTrue(set.isEmpty()); |
87 |
|
return set.tailSet(m1, true); |
88 |
|
} |
89 |
|
|
90 |
< |
private static NavigableSet dset0() { |
90 |
> |
private static NavigableSet dset0() { |
91 |
|
ConcurrentSkipListSet set = new ConcurrentSkipListSet(); |
92 |
|
assertTrue(set.isEmpty()); |
93 |
|
return set; |
94 |
|
} |
95 |
< |
|
95 |
> |
|
96 |
|
/** |
97 |
|
* A new set has unbounded capacity |
98 |
|
*/ |
138 |
|
NavigableSet q = set0(); |
139 |
|
q.add(null); |
140 |
|
shouldThrow(); |
141 |
< |
} catch (NullPointerException success) { } |
141 |
> |
} catch (NullPointerException success) { } |
142 |
|
} |
143 |
|
|
144 |
|
/** |
255 |
|
} |
256 |
|
assertTrue(q.isEmpty()); |
257 |
|
} |
258 |
< |
|
258 |
> |
|
259 |
|
/** |
260 |
|
* contains(x) reports true when elements added but not yet removed |
261 |
|
*/ |
331 |
|
} |
332 |
|
} |
333 |
|
|
334 |
< |
|
334 |
> |
|
335 |
|
|
336 |
|
/** |
337 |
|
* lower returns preceding element |
431 |
|
for(int i = 0; i < ints.length; i++) |
432 |
|
assertEquals(ints[i], q.pollFirst()); |
433 |
|
} |
434 |
< |
|
434 |
> |
|
435 |
|
/** |
436 |
|
* iterator iterates through all elements |
437 |
|
*/ |
489 |
|
for (int i = 0; i < SIZE; ++i) { |
490 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
491 |
|
} |
492 |
< |
} |
492 |
> |
} |
493 |
|
|
494 |
|
/** |
495 |
< |
* A deserialized serialized set has same elements |
495 |
> |
* A deserialized serialized set has same elements |
496 |
|
*/ |
497 |
|
public void testSerialization() { |
498 |
|
NavigableSet q = populatedSet(SIZE); |
506 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
507 |
|
NavigableSet r = (NavigableSet)in.readObject(); |
508 |
|
assertEquals(q.size(), r.size()); |
509 |
< |
while (!q.isEmpty()) |
509 |
> |
while (!q.isEmpty()) |
510 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
511 |
|
} catch(Exception e){ |
512 |
|
e.printStackTrace(); |
656 |
|
NavigableSet q = dset0(); |
657 |
|
q.add(null); |
658 |
|
shouldThrow(); |
659 |
< |
} catch (NullPointerException success) { } |
659 |
> |
} catch (NullPointerException success) { } |
660 |
|
} |
661 |
|
|
662 |
|
/** |
773 |
|
} |
774 |
|
assertTrue(q.isEmpty()); |
775 |
|
} |
776 |
< |
|
776 |
> |
|
777 |
|
/** |
778 |
|
* contains(x) reports true when elements added but not yet removed |
779 |
|
*/ |
849 |
|
} |
850 |
|
} |
851 |
|
|
852 |
< |
|
852 |
> |
|
853 |
|
|
854 |
|
/** |
855 |
|
* lower returns preceding element |
949 |
|
for(int i = 0; i < ints.length; i++) |
950 |
|
assertEquals(ints[i], q.pollFirst()); |
951 |
|
} |
952 |
< |
|
952 |
> |
|
953 |
|
/** |
954 |
|
* iterator iterates through all elements |
955 |
|
*/ |
1007 |
|
for (int i = 0; i < SIZE; ++i) { |
1008 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
1009 |
|
} |
1010 |
< |
} |
1010 |
> |
} |
1011 |
|
|
1012 |
|
/** |
1013 |
< |
* A deserialized serialized set has same elements |
1013 |
> |
* A deserialized serialized set has same elements |
1014 |
|
*/ |
1015 |
|
public void testDescendingSerialization() { |
1016 |
|
NavigableSet q = populatedSet(SIZE); |
1024 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1025 |
|
NavigableSet r = (NavigableSet)in.readObject(); |
1026 |
|
assertEquals(q.size(), r.size()); |
1027 |
< |
while (!q.isEmpty()) |
1027 |
> |
while (!q.isEmpty()) |
1028 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
1029 |
|
} catch(Exception e){ |
1030 |
|
e.printStackTrace(); |