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

Comparing jsr166/src/test/tck/TreeSubSetTest.java (file contents):
Revision 1.19 by jsr166, Fri May 27 19:10:32 2011 UTC vs.
Revision 1.20 by jsr166, Tue May 31 16:16:24 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.Comparator;
10 > import java.util.Iterator;
11 > import java.util.NavigableSet;
12 > import java.util.SortedSet;
13 > import java.util.TreeSet;
14  
15   public class TreeSubSetTest extends JSR166TestCase {
16      public static void main(String[] args) {
# Line 93 | Line 96 | public class TreeSubSetTest extends JSR1
96          assertEquals(0, set0().size());
97      }
98  
96
99      /**
100       * isEmpty is true before add, false after
101       */
# Line 164 | Line 166 | public class TreeSubSetTest extends JSR1
166          } catch (ClassCastException success) {}
167      }
168  
167
169      /**
170       * addAll(null) throws NPE
171       */
# Line 325 | Line 326 | public class TreeSubSetTest extends JSR1
326          }
327      }
328  
328
329
329      /**
330       * lower returns preceding element
331       */
# Line 468 | Line 467 | public class TreeSubSetTest extends JSR1
467          assertFalse(it.hasNext());
468      }
469  
471
470      /**
471       * toString contains toStrings of elements
472       */
# Line 484 | Line 482 | public class TreeSubSetTest extends JSR1
482       * A deserialized serialized set has same elements
483       */
484      public void testSerialization() throws Exception {
485 <        NavigableSet q = populatedSet(SIZE);
486 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
487 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
488 <        out.writeObject(q);
489 <        out.close();
490 <
491 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
492 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
493 <        NavigableSet r = (NavigableSet)in.readObject();
494 <        assertEquals(q.size(), r.size());
495 <        while (!q.isEmpty())
496 <            assertEquals(q.pollFirst(), r.pollFirst());
485 >        NavigableSet x = populatedSet(SIZE);
486 >        NavigableSet y = serialClone(x);
487 >
488 >        assertTrue(x != y);
489 >        assertEquals(x.size(), y.size());
490 >        assertEquals(x, y);
491 >        assertEquals(y, x);
492 >        while (!x.isEmpty()) {
493 >            assertFalse(y.isEmpty());
494 >            assertEquals(x.pollFirst(), y.pollFirst());
495 >        }
496 >        assertTrue(y.isEmpty());
497      }
498  
499      /**
# Line 662 | Line 660 | public class TreeSubSetTest extends JSR1
660          } catch (ClassCastException success) {}
661      }
662  
665
663      /**
664       * addAll(null) throws NPE
665       */
# Line 817 | Line 814 | public class TreeSubSetTest extends JSR1
814          }
815      }
816  
820
821
817      /**
818       * lower returns preceding element
819       */
# Line 961 | Line 956 | public class TreeSubSetTest extends JSR1
956          assertFalse(it.hasNext());
957      }
958  
964
959      /**
960       * toString contains toStrings of elements
961       */
# Line 977 | Line 971 | public class TreeSubSetTest extends JSR1
971       * A deserialized serialized set has same elements
972       */
973      public void testDescendingSerialization() throws Exception {
974 <        NavigableSet q = populatedSet(SIZE);
975 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
976 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
977 <        out.writeObject(q);
978 <        out.close();
979 <
980 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
981 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
982 <        NavigableSet r = (NavigableSet)in.readObject();
983 <        assertEquals(q.size(), r.size());
984 <        while (!q.isEmpty())
985 <            assertEquals(q.pollFirst(), r.pollFirst());
974 >        NavigableSet x = dset5();
975 >        NavigableSet y = serialClone(x);
976 >
977 >        assertTrue(x != y);
978 >        assertEquals(x.size(), y.size());
979 >        assertEquals(x.toString(), y.toString());
980 >        assertEquals(x, y);
981 >        assertEquals(y, x);
982 >        while (!x.isEmpty()) {
983 >            assertFalse(y.isEmpty());
984 >            assertEquals(x.pollFirst(), y.pollFirst());
985 >        }
986 >        assertTrue(y.isEmpty());
987      }
988  
989      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines