ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java (file contents):
Revision 1.19 by jsr166, Fri May 27 19:21:27 2011 UTC vs.
Revision 1.20 by jsr166, Tue May 31 16:16:23 2011 UTC

# Line 5 | Line 5
5   */
6  
7   import junit.framework.*;
8 < import java.util.*;
9 < import java.util.concurrent.*;
10 < import java.io.*;
8 > import java.util.Arrays;
9 > import java.util.BitSet;
10 > import java.util.Collection;
11 > import java.util.Comparator;
12 > import java.util.Iterator;
13 > import java.util.NavigableSet;
14 > import java.util.NoSuchElementException;
15 > import java.util.Random;
16 > import java.util.Set;
17 > import java.util.SortedSet;
18 > import java.util.concurrent.ConcurrentSkipListSet;
19  
20   public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
21      public static void main(String[] args) {
# Line 483 | Line 491 | public class ConcurrentSkipListSubSetTes
491       * A deserialized serialized set has same elements
492       */
493      public void testSerialization() throws Exception {
494 <        NavigableSet q = populatedSet(SIZE);
495 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
496 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
497 <        out.writeObject(q);
498 <        out.close();
499 <
500 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
501 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
502 <        NavigableSet r = (NavigableSet)in.readObject();
503 <        assertEquals(q.size(), r.size());
504 <        while (!q.isEmpty())
505 <            assertEquals(q.pollFirst(), r.pollFirst());
494 >        NavigableSet x = populatedSet(SIZE);
495 >        NavigableSet y = serialClone(x);
496 >
497 >        assertTrue(x != y);
498 >        assertEquals(x.size(), y.size());
499 >        assertEquals(x, y);
500 >        assertEquals(y, x);
501 >        while (!x.isEmpty()) {
502 >            assertFalse(y.isEmpty());
503 >            assertEquals(x.pollFirst(), y.pollFirst());
504 >        }
505 >        assertTrue(y.isEmpty());
506      }
507  
508      /**
# Line 983 | Line 991 | public class ConcurrentSkipListSubSetTes
991       * A deserialized serialized set has same elements
992       */
993      public void testDescendingSerialization() throws Exception {
994 <        NavigableSet q = populatedSet(SIZE);
995 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
996 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
997 <        out.writeObject(q);
998 <        out.close();
999 <
1000 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
1001 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1002 <        NavigableSet r = (NavigableSet)in.readObject();
1003 <        assertEquals(q.size(), r.size());
1004 <        while (!q.isEmpty())
1005 <            assertEquals(q.pollFirst(), r.pollFirst());
994 >        NavigableSet x = dset5();
995 >        NavigableSet y = serialClone(x);
996 >
997 >        assertTrue(x != y);
998 >        assertEquals(x.size(), y.size());
999 >        assertEquals(x, y);
1000 >        assertEquals(y, x);
1001 >        while (!x.isEmpty()) {
1002 >            assertFalse(y.isEmpty());
1003 >            assertEquals(x.pollFirst(), y.pollFirst());
1004 >        }
1005 >        assertTrue(y.isEmpty());
1006      }
1007  
1008      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines