assertEquals(5, subDescendingMap.size());
}
public void test_DescendingSubMap_tailMap() {
// tm
NavigableMap decendingMap = tm.descendingMap();
String endKey = new Integer(1000).toString(), key;
SortedMap subDecendingMap_Included = decendingMap.tailMap(endKey, true);
SortedMap subDecendingMap_Excluded = decendingMap
.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
key = new Integer(100).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
key = new Integer(10).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
key = new Integer(1).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
key = new Integer(0).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(999).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 998; i > 0; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(0).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(0).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
assertEquals(1, subDecendingMap_Included.size());
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.isEmpty());
// navigableMap_startExcluded_endExcluded
decendingMap = navigableMap_startExcluded_endExcluded.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertFalse(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(1, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(100).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
// navigableMap_startExcluded_endIncluded
decendingMap = navigableMap_startExcluded_endIncluded.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertFalse(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(1, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(100).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
// navigableMap_startIncluded_endExcluded
decendingMap = navigableMap_startIncluded_endExcluded.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
try {
decendingMap.tailMap(endKey, true);
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(2, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(100).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
// navigableMap_startIncluded_endIncluded
decendingMap = navigableMap_startIncluded_endIncluded.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
try {
decendingMap.tailMap(endKey, true);
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(2, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(100).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
// With Comparator
decendingMap = ((NavigableMap) subMap_startExcluded_endExcluded_comparator)
.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertFalse(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(1, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(100).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
decendingMap = ((NavigableMap) subMap_startExcluded_endIncluded_comparator)
.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertFalse(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(1, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(100).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
assertTrue(subDecendingMap_Excluded.isEmpty());
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
// navigableMap_startIncluded_endExcluded
decendingMap = ((NavigableMap) subMap_startIncluded_endExcluded)
.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
try {
decendingMap.tailMap(endKey, true);
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(2, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(100).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
decendingMap = ((NavigableMap) subMap_startIncluded_endIncluded)
.descendingMap();
endKey = new Integer(110).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
endKey = new Integer(109).toString();
try {
decendingMap.tailMap(endKey, true);
} catch (IllegalArgumentException e) {
// Expected
}
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(108).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
for (int i = 107; i > 100; i--) {
key = new Integer(i).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Excluded.containsKey(key));
}
key = new Integer(100).toString();
assertTrue(subDecendingMap_Included.containsKey(key));
assertTrue(subDecendingMap_Included.containsKey(key));
endKey = new Integer(101).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertEquals(2, subDecendingMap_Included.size());
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(100).toString();
subDecendingMap_Included = decendingMap.tailMap(endKey, true);
subDecendingMap_Excluded = decendingMap.tailMap(endKey, false);
key = endKey;
assertTrue(subDecendingMap_Included.containsKey(key));
assertFalse(subDecendingMap_Excluded.containsKey(key));
endKey = new Integer(99).toString();
try {
decendingMap.tailMap(endKey, true);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
try {
decendingMap.tailMap(endKey, false);
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected
}
}