--- jsr166/src/test/tck/TreeMapTest.java 2012/02/21 01:54:04 1.24 +++ jsr166/src/test/tck/TreeMapTest.java 2015/02/28 18:33:42 1.30 @@ -4,8 +4,20 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import junit.framework.*; -import java.util.*; +import java.util.Arrays; +import java.util.BitSet; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import java.util.NavigableMap; +import java.util.NavigableSet; +import java.util.NoSuchElementException; +import java.util.Random; +import java.util.Set; +import java.util.TreeMap; + +import junit.framework.Test; +import junit.framework.TestSuite; public class TreeMapTest extends JSR166TestCase { public static void main(String[] args) { @@ -16,7 +28,7 @@ public class TreeMapTest extends JSR166T } /** - * Creates a map from Integers 1-5 to Strings "A"-"E". + * Returns a new map from Integers 1-5 to Strings "A"-"E". */ private static TreeMap map5() { TreeMap map = new TreeMap(); @@ -41,7 +53,7 @@ public class TreeMapTest extends JSR166T } /** - * + * copy constructor creates map equal to source map */ public void testConstructFromSorted() { TreeMap map = map5(); @@ -563,8 +575,8 @@ public class TreeMapTest extends JSR166T * get(null) of nonempty map throws NPE */ public void testGet_NullPointerException() { + TreeMap c = map5(); try { - TreeMap c = map5(); c.get(null); shouldThrow(); } catch (NullPointerException success) {} @@ -574,8 +586,8 @@ public class TreeMapTest extends JSR166T * containsKey(null) of nonempty map throws NPE */ public void testContainsKey_NullPointerException() { + TreeMap c = map5(); try { - TreeMap c = map5(); c.containsKey(null); shouldThrow(); } catch (NullPointerException success) {} @@ -585,9 +597,9 @@ public class TreeMapTest extends JSR166T * remove(null) throws NPE for nonempty map */ public void testRemove1_NullPointerException() { + TreeMap c = new TreeMap(); + c.put("sadsdf", "asdads"); try { - TreeMap c = new TreeMap(); - c.put("sadsdf", "asdads"); c.remove(null); shouldThrow(); } catch (NullPointerException success) {} @@ -600,7 +612,7 @@ public class TreeMapTest extends JSR166T NavigableMap x = map5(); NavigableMap y = serialClone(x); - assertTrue(x != y); + assertNotSame(x, y); assertEquals(x.size(), y.size()); assertEquals(x.toString(), y.toString()); assertEquals(x, y); @@ -823,7 +835,7 @@ public class TreeMapTest extends JSR166T // Add entries till we're back to original size while (map.size() < size) { int key = min + rnd.nextInt(rangeSize); - assertTrue(key >= min && key<= max); + assertTrue(key >= min && key <= max); put(map, key); } } @@ -848,7 +860,7 @@ public class TreeMapTest extends JSR166T // Add entries till we're back to original size while (map.size() < size) { int key = min - 5 + rnd.nextInt(rangeSize + 10); - if (key >= min && key<= max) { + if (key >= min && key <= max) { put(map, key); } else { try {