--- jsr166/src/test/tck/TreeMapTest.java 2009/11/21 17:38:06 1.11 +++ jsr166/src/test/tck/TreeMapTest.java 2011/04/14 22:55:08 1.19 @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ import junit.framework.*; @@ -11,7 +11,7 @@ import java.io.*; public class TreeMapTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); + junit.textui.TestRunner.run(suite()); } public static Test suite() { return new TestSuite(TreeMapTest.class); @@ -34,7 +34,7 @@ public class TreeMapTest extends JSR166T } /** - * clear removes all pairs + * clear removes all pairs */ public void testClear() { TreeMap map = map5(); @@ -52,7 +52,7 @@ public class TreeMapTest extends JSR166T } /** - * Maps with same contents are equal + * Maps with same contents are equal */ public void testEquals() { TreeMap map1 = map5(); @@ -65,7 +65,7 @@ public class TreeMapTest extends JSR166T } /** - * containsKey returns true for contained key + * containsKey returns true for contained key */ public void testContainsKey() { TreeMap map = map5(); @@ -74,7 +74,7 @@ public class TreeMapTest extends JSR166T } /** - * containsValue returns true for held values + * containsValue returns true for held values */ public void testContainsValue() { TreeMap map = map5(); @@ -83,8 +83,8 @@ public class TreeMapTest extends JSR166T } /** - * get returns the correct element at the given key, - * or null if not present + * get returns the correct element at the given key, + * or null if not present */ public void testGet() { TreeMap map = map5(); @@ -94,7 +94,7 @@ public class TreeMapTest extends JSR166T } /** - * isEmpty is true of empty map and false for non-empty + * isEmpty is true of empty map and false for non-empty */ public void testIsEmpty() { TreeMap empty = new TreeMap(); @@ -104,7 +104,7 @@ public class TreeMapTest extends JSR166T } /** - * firstKey returns first key + * firstKey returns first key */ public void testFirstKey() { TreeMap map = map5(); @@ -112,7 +112,7 @@ public class TreeMapTest extends JSR166T } /** - * lastKey returns last key + * lastKey returns last key */ public void testLastKey() { TreeMap map = map5(); @@ -121,7 +121,7 @@ public class TreeMapTest extends JSR166T /** - * keySet.toArray returns contains all keys + * keySet.toArray returns contains all keys */ public void testKeySetToArray() { TreeMap map = map5(); @@ -134,7 +134,7 @@ public class TreeMapTest extends JSR166T } /** - * descendingkeySet.toArray returns contains all keys + * descendingkeySet.toArray returns contains all keys */ public void testDescendingKeySetToArray() { TreeMap map = map5(); @@ -147,7 +147,7 @@ public class TreeMapTest extends JSR166T } /** - * keySet returns a Set containing all the keys + * keySet returns a Set containing all the keys */ public void testKeySet() { TreeMap map = map5(); @@ -161,7 +161,7 @@ public class TreeMapTest extends JSR166T } /** - * keySet is ordered + * keySet is ordered */ public void testKeySetOrder() { TreeMap map = map5(); @@ -199,7 +199,7 @@ public class TreeMapTest extends JSR166T } /** - * descendingKeySet is ordered + * descendingKeySet is ordered */ public void testDescendingKeySetOrder() { TreeMap map = map5(); @@ -218,7 +218,7 @@ public class TreeMapTest extends JSR166T } /** - * descending iterator of descendingKeySet is ordered + * descending iterator of descendingKeySet is ordered */ public void testDescendingKeySetDescendingIteratorOrder() { TreeMap map = map5(); @@ -289,7 +289,7 @@ public class TreeMapTest extends JSR166T } /** - * entrySet.toArray contains all entries + * entrySet.toArray contains all entries */ public void testEntrySetToArray() { TreeMap map = map5(); @@ -303,7 +303,7 @@ public class TreeMapTest extends JSR166T } /** - * descendingEntrySet.toArray contains all entries + * descendingEntrySet.toArray contains all entries */ public void testDescendingEntrySetToArray() { TreeMap map = map5(); @@ -317,7 +317,7 @@ public class TreeMapTest extends JSR166T } /** - * putAll adds all key-value pairs from the given map + * putAll adds all key-value pairs from the given map */ public void testPutAll() { TreeMap empty = new TreeMap(); @@ -332,7 +332,7 @@ public class TreeMapTest extends JSR166T } /** - * remove removes the correct key-value pair from the map + * remove removes the correct key-value pair from the map */ public void testRemove() { TreeMap map = map5(); @@ -357,7 +357,6 @@ public class TreeMapTest extends JSR166T Map.Entry e4 = map.lowerEntry(zero); assertNull(e4); - } /** @@ -376,7 +375,6 @@ public class TreeMapTest extends JSR166T Map.Entry e4 = map.higherEntry(six); assertNull(e4); - } /** @@ -395,7 +393,6 @@ public class TreeMapTest extends JSR166T Map.Entry e4 = map.floorEntry(zero); assertNull(e4); - } /** @@ -414,7 +411,6 @@ public class TreeMapTest extends JSR166T Map.Entry e4 = map.ceilingEntry(six); assertNull(e4); - } @@ -434,7 +430,6 @@ public class TreeMapTest extends JSR166T Object e4 = q.lowerKey(zero); assertNull(e4); - } /** @@ -453,7 +448,6 @@ public class TreeMapTest extends JSR166T Object e4 = q.higherKey(six); assertNull(e4); - } /** @@ -472,7 +466,6 @@ public class TreeMapTest extends JSR166T Object e4 = q.floorKey(zero); assertNull(e4); - } /** @@ -491,7 +484,6 @@ public class TreeMapTest extends JSR166T Object e4 = q.ceilingKey(six); assertNull(e4); - } /** @@ -549,7 +541,7 @@ public class TreeMapTest extends JSR166T } /** - * size returns the correct values + * size returns the correct values */ public void testSize() { TreeMap map = map5(); @@ -660,7 +652,7 @@ public class TreeMapTest extends JSR166T assertEquals(1, sm.size()); assertEquals(three, sm.firstKey()); assertEquals(three, sm.lastKey()); - assertTrue(sm.remove(three) != null); + assertEquals("C", sm.remove(three)); assertTrue(sm.isEmpty()); assertEquals(3, map.size()); } @@ -693,7 +685,7 @@ public class TreeMapTest extends JSR166T assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); - assertTrue(sm.remove(three) == null); + assertSame(sm.remove(three), null); assertEquals(4, map.size()); } @@ -775,7 +767,7 @@ public class TreeMapTest extends JSR166T NavigableMap ssm = sm.tailMap(four, true); assertEquals(four, ssm.firstKey()); assertEquals(five, ssm.lastKey()); - assertTrue(ssm.remove(four) != null); + assertEquals("D", ssm.remove(four)); assertEquals(1, ssm.size()); assertEquals(3, sm.size()); assertEquals(4, map.size()); @@ -788,7 +780,7 @@ public class TreeMapTest extends JSR166T * Submaps of submaps subdivide correctly */ public void testRecursiveSubMaps() throws Exception { - int mapSize = 1000; + int mapSize = expensiveTests ? 1000 : 100; Class cl = TreeMap.class; NavigableMap map = newMap(cl); bs = new BitSet(mapSize); @@ -969,7 +961,7 @@ public class TreeMapTest extends JSR166T */ void check(NavigableMap map, final int min, final int max, final boolean ascending) { - class ReferenceSet { + class ReferenceSet { int lower(int key) { return ascending ? lowerAscending(key) : higherAscending(key); } @@ -1000,7 +992,7 @@ public class TreeMapTest extends JSR166T // BitSet should support this! Test would run much faster while (key >= min) { if (bs.get(key)) - return(key); + return key; key--; } return -1;