11 |
|
|
12 |
|
public class TreeSubSetTest 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(TreeSubSetTest.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(); |
78 |
|
return s; |
79 |
|
} |
80 |
|
|
81 |
< |
private static NavigableSet set0() { |
81 |
> |
private static NavigableSet set0() { |
82 |
|
TreeSet set = new TreeSet(); |
83 |
|
assertTrue(set.isEmpty()); |
84 |
|
return set.tailSet(m1, false); |
85 |
|
} |
86 |
|
|
87 |
< |
private static NavigableSet dset0() { |
87 |
> |
private static NavigableSet dset0() { |
88 |
|
TreeSet set = new TreeSet(); |
89 |
|
assertTrue(set.isEmpty()); |
90 |
|
return set; |
91 |
|
} |
92 |
< |
|
92 |
> |
|
93 |
|
/** |
94 |
|
* A new set has unbounded capacity |
95 |
|
*/ |
135 |
|
NavigableSet q = set0(); |
136 |
|
q.add(null); |
137 |
|
shouldThrow(); |
138 |
< |
} catch (NullPointerException success) { } |
138 |
> |
} catch (NullPointerException success) { } |
139 |
|
} |
140 |
|
|
141 |
|
/** |
252 |
|
} |
253 |
|
assertTrue(q.isEmpty()); |
254 |
|
} |
255 |
< |
|
255 |
> |
|
256 |
|
/** |
257 |
|
* contains(x) reports true when elements added but not yet removed |
258 |
|
*/ |
328 |
|
} |
329 |
|
} |
330 |
|
|
331 |
< |
|
331 |
> |
|
332 |
|
|
333 |
|
/** |
334 |
|
* lower returns preceding element |
428 |
|
for(int i = 0; i < ints.length; i++) |
429 |
|
assertEquals(ints[i], q.pollFirst()); |
430 |
|
} |
431 |
< |
|
431 |
> |
|
432 |
|
/** |
433 |
|
* iterator iterates through all elements |
434 |
|
*/ |
486 |
|
for (int i = 0; i < SIZE; ++i) { |
487 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
488 |
|
} |
489 |
< |
} |
489 |
> |
} |
490 |
|
|
491 |
|
/** |
492 |
< |
* A deserialized serialized set has same elements |
492 |
> |
* A deserialized serialized set has same elements |
493 |
|
*/ |
494 |
|
public void testSerialization() { |
495 |
|
NavigableSet q = populatedSet(SIZE); |
503 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
504 |
|
NavigableSet r = (NavigableSet)in.readObject(); |
505 |
|
assertEquals(q.size(), r.size()); |
506 |
< |
while (!q.isEmpty()) |
506 |
> |
while (!q.isEmpty()) |
507 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
508 |
|
} catch(Exception e){ |
509 |
|
e.printStackTrace(); |
759 |
|
} |
760 |
|
assertTrue(q.isEmpty()); |
761 |
|
} |
762 |
< |
|
762 |
> |
|
763 |
|
/** |
764 |
|
* contains(x) reports true when elements added but not yet removed |
765 |
|
*/ |
835 |
|
} |
836 |
|
} |
837 |
|
|
838 |
< |
|
838 |
> |
|
839 |
|
|
840 |
|
/** |
841 |
|
* lower returns preceding element |
935 |
|
for(int i = 0; i < ints.length; i++) |
936 |
|
assertEquals(ints[i], q.pollFirst()); |
937 |
|
} |
938 |
< |
|
938 |
> |
|
939 |
|
/** |
940 |
|
* iterator iterates through all elements |
941 |
|
*/ |
993 |
|
for (int i = 0; i < SIZE; ++i) { |
994 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
995 |
|
} |
996 |
< |
} |
996 |
> |
} |
997 |
|
|
998 |
|
/** |
999 |
< |
* A deserialized serialized set has same elements |
999 |
> |
* A deserialized serialized set has same elements |
1000 |
|
*/ |
1001 |
|
public void testDescendingSerialization() { |
1002 |
|
NavigableSet q = populatedSet(SIZE); |
1010 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1011 |
|
NavigableSet r = (NavigableSet)in.readObject(); |
1012 |
|
assertEquals(q.size(), r.size()); |
1013 |
< |
while (!q.isEmpty()) |
1013 |
> |
while (!q.isEmpty()) |
1014 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
1015 |
|
} catch(Exception e){ |
1016 |
|
e.printStackTrace(); |