--- jsr166/src/test/tck/TreeMapTest.java 2006/04/19 15:10:54 1.3 +++ jsr166/src/test/tck/TreeMapTest.java 2008/04/19 18:45:18 1.5 @@ -169,11 +169,33 @@ public class TreeMapTest extends JSR166T Iterator i = s.iterator(); Integer last = (Integer)i.next(); assertEquals(last, one); + int count = 1; while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) < 0); last = k; + ++count; } + assertEquals(count ,5); + } + + /** + * descending iterator of key set is inverse ordered + */ + public void testKeySetDescendingIteratorOrder() { + TreeMap map = map5(); + NavigableSet s = map.navigableKeySet(); + Iterator i = s.descendingIterator(); + Integer last = (Integer)i.next(); + assertEquals(last, five); + int count = 1; + while (i.hasNext()) { + Integer k = (Integer)i.next(); + assertTrue(last.compareTo(k) > 0); + last = k; + ++count; + } + assertEquals(count ,5); } /** @@ -185,11 +207,33 @@ public class TreeMapTest extends JSR166T Iterator i = s.iterator(); Integer last = (Integer)i.next(); assertEquals(last, five); + int count = 1; while (i.hasNext()) { Integer k = (Integer)i.next(); assertTrue(last.compareTo(k) > 0); last = k; + ++count; + } + assertEquals(count, 5); + } + + /** + * descending iterator of descendingKeySet is ordered + */ + public void testDescendingKeySetDescendingIteratorOrder() { + TreeMap map = map5(); + NavigableSet s = map.descendingKeySet(); + Iterator i = s.descendingIterator(); + Integer last = (Integer)i.next(); + assertEquals(last, one); + int count = 1; + while (i.hasNext()) { + Integer k = (Integer)i.next(); + assertTrue(last.compareTo(k) < 0); + last = k; + ++count; } + assertEquals(count, 5); } /** @@ -592,7 +636,7 @@ public class TreeMapTest extends JSR166T */ public void testSubMapContents() { TreeMap map = map5(); - NavigableMap sm = map.navigableSubMap(two, true, four, false); + NavigableMap sm = map.subMap(two, true, four, false); assertEquals(two, sm.firstKey()); assertEquals(three, sm.lastKey()); assertEquals(2, sm.size()); @@ -630,7 +674,7 @@ public class TreeMapTest extends JSR166T public void testSubMapContents2() { TreeMap map = map5(); - NavigableMap sm = map.navigableSubMap(two, true, three, false); + NavigableMap sm = map.subMap(two, true, three, false); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); @@ -665,7 +709,7 @@ public class TreeMapTest extends JSR166T */ public void testHeadMapContents() { TreeMap map = map5(); - NavigableMap sm = map.navigableHeadMap(four, false); + NavigableMap sm = map.headMap(four, false); assertTrue(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); @@ -691,7 +735,7 @@ public class TreeMapTest extends JSR166T */ public void testTailMapContents() { TreeMap map = map5(); - NavigableMap sm = map.navigableTailMap(two, true); + NavigableMap sm = map.tailMap(two, true); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertTrue(sm.containsKey(three)); @@ -735,7 +779,7 @@ public class TreeMapTest extends JSR166T assertEquals("E", e.getValue()); assertFalse(i.hasNext()); - NavigableMap ssm = sm.navigableTailMap(four, true); + NavigableMap ssm = sm.tailMap(four, true); assertEquals(four, ssm.firstKey()); assertEquals(five, ssm.lastKey()); assertTrue(ssm.remove(four) != null); @@ -764,7 +808,7 @@ public class TreeMapTest extends JSR166T check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); - bashSubMap(map.navigableSubMap(0, true, mapSize, false), + bashSubMap(map.subMap(0, true, mapSize, false), 0, mapSize - 1, true); } @@ -871,7 +915,7 @@ public class TreeMapTest extends JSR166T // headMap - pick direction and endpoint inclusion randomly boolean incl = rnd.nextBoolean(); - NavigableMap hm = map.navigableHeadMap(midPoint, incl); + NavigableMap hm = map.headMap(midPoint, incl); if (ascending) { if (rnd.nextBoolean()) bashSubMap(hm, min, midPoint - (incl ? 0 : 1), true); @@ -888,7 +932,7 @@ public class TreeMapTest extends JSR166T // tailMap - pick direction and endpoint inclusion randomly incl = rnd.nextBoolean(); - NavigableMap tm = map.navigableTailMap(midPoint,incl); + NavigableMap tm = map.tailMap(midPoint,incl); if (ascending) { if (rnd.nextBoolean()) bashSubMap(tm, midPoint + (incl ? 0 : 1), max, true); @@ -913,7 +957,7 @@ public class TreeMapTest extends JSR166T boolean lowIncl = rnd.nextBoolean(); boolean highIncl = rnd.nextBoolean(); if (ascending) { - NavigableMap sm = map.navigableSubMap( + NavigableMap sm = map.subMap( endpoints[0], lowIncl, endpoints[1], highIncl); if (rnd.nextBoolean()) bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), @@ -922,7 +966,7 @@ public class TreeMapTest extends JSR166T bashSubMap(sm.descendingMap(), endpoints[0] + (lowIncl ? 0 : 1), endpoints[1] - (highIncl ? 0 : 1), false); } else { - NavigableMap sm = map.navigableSubMap( + NavigableMap sm = map.subMap( endpoints[1], highIncl, endpoints[0], lowIncl); if (rnd.nextBoolean()) bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1),