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

Comparing jsr166/src/test/tck/TreeMapTest.java (file contents):
Revision 1.26 by jsr166, Wed Jan 2 07:41:07 2013 UTC vs.
Revision 1.34 by jsr166, Wed Aug 23 05:33:00 2017 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.*;
7 > import java.util.Arrays;
8 > import java.util.BitSet;
9 > import java.util.Collection;
10 > import java.util.Iterator;
11 > import java.util.Map;
12 > import java.util.NavigableMap;
13 > import java.util.NavigableSet;
14 > import java.util.NoSuchElementException;
15 > import java.util.Random;
16 > import java.util.Set;
17 > import java.util.TreeMap;
18 >
19 > import junit.framework.Test;
20  
21   public class TreeMapTest extends JSR166TestCase {
22      public static void main(String[] args) {
23 <        junit.textui.TestRunner.run(suite());
23 >        main(suite(), args);
24      }
25      public static Test suite() {
26 <        return new TestSuite(TreeMapTest.class);
26 >        class Implementation implements MapImplementation {
27 >            public Class<?> klazz() { return TreeMap.class; }
28 >            public Map emptyMap() { return new TreeMap(); }
29 >            public Object makeKey(int i) { return i; }
30 >            public Object makeValue(int i) { return i; }
31 >            public boolean isConcurrent() { return false; }
32 >            public boolean permitsNullKeys() { return false; }
33 >            public boolean permitsNullValues() { return true; }
34 >            public boolean supportsSetValue() { return true; }
35 >        }
36 >        return newTestSuite(
37 >            TreeMapTest.class,
38 >            MapTest.testSuite(new Implementation()));
39      }
40  
41      /**
# Line 563 | Line 586 | public class TreeMapTest extends JSR166T
586       * get(null) of nonempty map throws NPE
587       */
588      public void testGet_NullPointerException() {
589 +        TreeMap c = map5();
590          try {
567            TreeMap c = map5();
591              c.get(null);
592              shouldThrow();
593          } catch (NullPointerException success) {}
# Line 574 | Line 597 | public class TreeMapTest extends JSR166T
597       * containsKey(null) of nonempty map throws NPE
598       */
599      public void testContainsKey_NullPointerException() {
600 +        TreeMap c = map5();
601          try {
578            TreeMap c = map5();
602              c.containsKey(null);
603              shouldThrow();
604          } catch (NullPointerException success) {}
# Line 585 | Line 608 | public class TreeMapTest extends JSR166T
608       * remove(null) throws NPE for nonempty map
609       */
610      public void testRemove1_NullPointerException() {
611 +        TreeMap c = new TreeMap();
612 +        c.put("sadsdf", "asdads");
613          try {
589            TreeMap c = new TreeMap();
590            c.put("sadsdf", "asdads");
614              c.remove(null);
615              shouldThrow();
616          } catch (NullPointerException success) {}
617      }
618  
619      /**
620 <     * A deserialized map equals original
620 >     * A deserialized/reserialized map equals original
621       */
622      public void testSerialization() throws Exception {
623          NavigableMap x = map5();
624          NavigableMap y = serialClone(x);
625  
626 <        assertTrue(x != y);
626 >        assertNotSame(x, y);
627          assertEquals(x.size(), y.size());
628          assertEquals(x.toString(), y.toString());
629          assertEquals(x, y);
# Line 790 | Line 813 | public class TreeMapTest extends JSR166T
813  
814      static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
815          NavigableMap<Integer, Integer> result
816 <            = (NavigableMap<Integer, Integer>) cl.newInstance();
816 >            = (NavigableMap<Integer, Integer>) cl.getConstructor().newInstance();
817          assertEquals(0, result.size());
818          assertFalse(result.keySet().iterator().hasNext());
819          return result;
# Line 823 | Line 846 | public class TreeMapTest extends JSR166T
846          // Add entries till we're back to original size
847          while (map.size() < size) {
848              int key = min + rnd.nextInt(rangeSize);
849 <            assertTrue(key >= min && key<= max);
849 >            assertTrue(key >= min && key <= max);
850              put(map, key);
851          }
852      }
# Line 848 | Line 871 | public class TreeMapTest extends JSR166T
871          // Add entries till we're back to original size
872          while (map.size() < size) {
873              int key = min - 5 + rnd.nextInt(rangeSize + 10);
874 <            if (key >= min && key<= max) {
874 >            if (key >= min && key <= max) {
875                  put(map, key);
876              } else {
877                  try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines