use of java.util.TreeMap in project mapdb by jankotek.
the class TreeMapTest method testDescendingEntrySet.
/**
* descendingEntrySet contains all pairs
*/
public void testDescendingEntrySet() {
TreeMap map = map5();
Set s = map.descendingMap().entrySet();
assertEquals(5, s.size());
Iterator it = s.iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry) it.next();
assertTrue((e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || (e.getKey().equals(three) && e.getValue().equals("C")) || (e.getKey().equals(four) && e.getValue().equals("D")) || (e.getKey().equals(five) && e.getValue().equals("E")));
}
}
use of java.util.TreeMap in project mapdb by jankotek.
the class TreeMapTest method testValues.
/**
* values collection contains all values
*/
public void testValues() {
TreeMap map = map5();
Collection s = map.values();
assertEquals(5, s.size());
assertTrue(s.contains("A"));
assertTrue(s.contains("B"));
assertTrue(s.contains("C"));
assertTrue(s.contains("D"));
assertTrue(s.contains("E"));
}
use of java.util.TreeMap in project mapdb by jankotek.
the class TreeMapTest method testKeySet.
/**
* keySet returns a Set containing all the keys
*/
public void testKeySet() {
TreeMap map = map5();
Set s = map.keySet();
assertEquals(5, s.size());
assertTrue(s.contains(one));
assertTrue(s.contains(two));
assertTrue(s.contains(three));
assertTrue(s.contains(four));
assertTrue(s.contains(five));
}
use of java.util.TreeMap in project mapdb by jankotek.
the class TreeMapTest method testGet_NullPointerException.
// Exception tests
/**
* get(null) of nonempty map throws NPE
*/
public void testGet_NullPointerException() {
TreeMap c = map5();
try {
c.get(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.TreeMap in project mapdb by jankotek.
the class TreeMapTest method testKeySetDescendingIteratorOrder.
/**
* 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(5, count);
}
Aggregations