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

Comparing jsr166/src/test/tck/TreeSetTest.java (file contents):
Revision 1.19 by jsr166, Thu Nov 18 20:21:54 2010 UTC vs.
Revision 1.23 by jsr166, Tue May 31 16:16:24 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
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.TreeSet;
19  
20   public class TreeSetTest extends JSR166TestCase {
21      public static void main(String[] args) {
# Line 273 | Line 281 | public class TreeSetTest extends JSR166T
281          assertNull(q.pollFirst());
282      }
283  
276
284      /**
285       * remove(x) removes x and returns true if present
286       */
# Line 370 | Line 377 | public class TreeSetTest extends JSR166T
377          }
378      }
379  
373
374
380      /**
381       * lower returns preceding element
382       */
# Line 513 | Line 518 | public class TreeSetTest extends JSR166T
518          assertFalse(it.hasNext());
519      }
520  
516
521      /**
522       * toString contains toStrings of elements
523       */
# Line 521 | Line 525 | public class TreeSetTest extends JSR166T
525          TreeSet q = populatedSet(SIZE);
526          String s = q.toString();
527          for (int i = 0; i < SIZE; ++i) {
528 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
528 >            assertTrue(s.contains(String.valueOf(i)));
529          }
530      }
531  
# Line 529 | Line 533 | public class TreeSetTest extends JSR166T
533       * A deserialized serialized set has same elements
534       */
535      public void testSerialization() throws Exception {
536 <        TreeSet q = populatedSet(SIZE);
537 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
538 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
539 <        out.writeObject(q);
540 <        out.close();
541 <
542 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
543 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
544 <        TreeSet r = (TreeSet)in.readObject();
545 <        assertEquals(q.size(), r.size());
546 <        while (!q.isEmpty())
547 <            assertEquals(q.pollFirst(), r.pollFirst());
536 >        NavigableSet x = populatedSet(SIZE);
537 >        NavigableSet y = serialClone(x);
538 >
539 >        assertTrue(x != y);
540 >        assertEquals(x.size(), y.size());
541 >        assertEquals(x, y);
542 >        assertEquals(y, x);
543 >        while (!x.isEmpty()) {
544 >            assertFalse(y.isEmpty());
545 >            assertEquals(x.pollFirst(), y.pollFirst());
546 >        }
547 >        assertTrue(y.isEmpty());
548      }
549  
550      /**
# Line 850 | Line 854 | public class TreeSetTest extends JSR166T
854       */
855      void check(NavigableSet<Integer> set,
856                        final int min, final int max, final boolean ascending) {
857 <       class ReferenceSet {
857 >        class ReferenceSet {
858              int lower(int element) {
859                  return ascending ?
860                      lowerAscending(element) : higherAscending(element);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines