11 |
|
|
12 |
|
public class TreeSetTest 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(TreeSetTest.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(); |
62 |
|
assertEquals(5, q.size()); |
63 |
|
return q; |
64 |
|
} |
65 |
< |
|
65 |
> |
|
66 |
|
/** |
67 |
|
* A new set has unbounded capacity |
68 |
|
*/ |
177 |
|
TreeSet q = populatedSet(SIZE); |
178 |
|
q.add(null); |
179 |
|
shouldThrow(); |
180 |
< |
} catch (NullPointerException success) { } |
180 |
> |
} catch (NullPointerException success) { } |
181 |
|
} |
182 |
|
|
183 |
|
/** |
306 |
|
} |
307 |
|
assertTrue(q.isEmpty()); |
308 |
|
} |
309 |
< |
|
309 |
> |
|
310 |
|
/** |
311 |
|
* contains(x) reports true when elements added but not yet removed |
312 |
|
*/ |
382 |
|
} |
383 |
|
} |
384 |
|
|
385 |
< |
|
385 |
> |
|
386 |
|
|
387 |
|
/** |
388 |
|
* lower returns preceding element |
482 |
|
for(int i = 0; i < ints.length; i++) |
483 |
|
assertEquals(ints[i], q.pollFirst()); |
484 |
|
} |
485 |
< |
|
485 |
> |
|
486 |
|
/** |
487 |
|
* iterator iterates through all elements |
488 |
|
*/ |
540 |
|
for (int i = 0; i < SIZE; ++i) { |
541 |
|
assertTrue(s.indexOf(String.valueOf(i)) >= 0); |
542 |
|
} |
543 |
< |
} |
543 |
> |
} |
544 |
|
|
545 |
|
/** |
546 |
< |
* A deserialized serialized set has same elements |
546 |
> |
* A deserialized serialized set has same elements |
547 |
|
*/ |
548 |
|
public void testSerialization() { |
549 |
|
TreeSet q = populatedSet(SIZE); |
557 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
558 |
|
TreeSet r = (TreeSet)in.readObject(); |
559 |
|
assertEquals(q.size(), r.size()); |
560 |
< |
while (!q.isEmpty()) |
560 |
> |
while (!q.isEmpty()) |
561 |
|
assertEquals(q.pollFirst(), r.pollFirst()); |
562 |
|
} catch(Exception e){ |
563 |
|
e.printStackTrace(); |