}
public void test_DescendingSubMapEntrySet_floor() {
Set entrySet;
NavigableSet ascendingSubMapEntrySet, descendingSet;
Entry entry;
Entry[] entryArray;
entrySet = navigableMap_startExcluded_endExcluded.entrySet();
if (entrySet instanceof NavigableSet) {
ascendingSubMapEntrySet = (NavigableSet) entrySet;
descendingSet = ascendingSubMapEntrySet.descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected
}
entryArray = (Entry[]) descendingSet
.toArray(new Entry[descendingSet.size()]);
for (int i = 0, j = 108; i < entryArray.length; i++) {
entry = (Entry) descendingSet.floor(entryArray[i]);
assertEquals(j - i, entry.getValue());
}
Object afterEnd = this.subMap_default_afterEnd_109.entrySet()
.iterator().next();
Object x = descendingSet.floor(afterEnd);
assertNull(x);
Object beforeStart = this.subMap_default_beforeStart_100.entrySet()
.iterator().next();
Object y = descendingSet.floor(beforeStart);
assertNotNull(y);
assertEquals(101, (((Entry) y).getValue()));
}
entrySet = navigableMap_startExcluded_endIncluded.entrySet();
if (entrySet instanceof NavigableSet) {
ascendingSubMapEntrySet = (NavigableSet) entrySet;
descendingSet = ascendingSubMapEntrySet.descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected
}
entryArray = (Entry[]) descendingSet
.toArray(new Entry[descendingSet.size()]);
for (int i = 0, j = 109; i < entryArray.length; i++) {
entry = (Entry) descendingSet.floor(entryArray[i]);
assertEquals(j - i, entry.getValue());
}
}
entrySet = navigableMap_startIncluded_endExcluded.entrySet();
if (entrySet instanceof NavigableSet) {
ascendingSubMapEntrySet = (NavigableSet) entrySet;
descendingSet = ascendingSubMapEntrySet.descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected
}
entryArray = (Entry[]) descendingSet
.toArray(new Entry[descendingSet.size()]);
for (int i = 0, j = 108; i < entryArray.length; i++) {
entry = (Entry) descendingSet.floor(entryArray[i]);
assertEquals(j - i, entry.getValue());
}
}
entrySet = navigableMap_startIncluded_endIncluded.entrySet();
if (entrySet instanceof NavigableSet) {
descendingSet = ((NavigableSet) entrySet).descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected
}
entryArray = (Entry[]) descendingSet
.toArray(new Entry[descendingSet.size()]);
for (int i = 0, j = 109; i < entryArray.length; i++) {
entry = (Entry) descendingSet.floor(entryArray[i]);
assertEquals(j - i, entry.getValue());
}
}
String endKey = new Integer(2).toString();
entrySet = tm.headMap(endKey, true).entrySet();
if (entrySet instanceof NavigableSet) {
descendingSet = ((NavigableSet) entrySet).descendingSet();
Iterator iterator = descendingSet.iterator();
Entry floorEntry;
while (iterator.hasNext()) {
entry = (Entry) iterator.next();
floorEntry = (Entry) descendingSet.floor(entry);
assertEquals(entry, floorEntry);
}
}
// With Comparator
entrySet = subMap_startExcluded_endExcluded_comparator.entrySet();
if (entrySet instanceof NavigableSet) {
ascendingSubMapEntrySet = (NavigableSet) entrySet;
descendingSet = ascendingSubMapEntrySet.descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected
}
entryArray = (Entry[]) descendingSet
.toArray(new Entry[descendingSet.size()]);
for (int i = 0, j = 108; i < entryArray.length; i++) {
entry = (Entry) descendingSet.floor(entryArray[i]);
assertEquals(j - i, entry.getValue());
}
}
entrySet = subMap_startExcluded_endIncluded_comparator.entrySet();
if (entrySet instanceof NavigableSet) {
ascendingSubMapEntrySet = (NavigableSet) entrySet;
descendingSet = ascendingSubMapEntrySet.descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected
}
entryArray = (Entry[]) descendingSet
.toArray(new Entry[descendingSet.size()]);
for (int i = 0, j = 109; i < entryArray.length; i++) {
entry = (Entry) descendingSet.floor(entryArray[i]);
assertEquals(j - i, entry.getValue());
}
}
entrySet = subMap_startIncluded_endExcluded_comparator.entrySet();
if (entrySet instanceof NavigableSet) {
ascendingSubMapEntrySet = (NavigableSet) entrySet;
descendingSet = ascendingSubMapEntrySet.descendingSet();
try {
descendingSet.floor(null);
fail("should throw NPE");
} catch (NullPointerException e) {
// Expected