use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testDescendingSubMapContents.
/**
* subMap returns map with keys in requested range
*/
public void testDescendingSubMapContents() {
NavigableMap map = dmap5();
SortedMap sm = map.subMap(m2, m4);
assertEquals(m2, sm.firstKey());
assertEquals(m3, sm.lastKey());
assertEquals(2, sm.size());
assertFalse(sm.containsKey(m1));
assertTrue(sm.containsKey(m2));
assertTrue(sm.containsKey(m3));
assertFalse(sm.containsKey(m4));
assertFalse(sm.containsKey(m5));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer) (i.next());
assertEquals(m2, k);
k = (Integer) (i.next());
assertEquals(m3, k);
assertFalse(i.hasNext());
Iterator j = sm.keySet().iterator();
j.next();
j.remove();
assertFalse(map.containsKey(m2));
assertEquals(4, map.size());
assertEquals(1, sm.size());
assertEquals(m3, sm.firstKey());
assertEquals(m3, sm.lastKey());
assertEquals("C", sm.remove(m3));
assertTrue(sm.isEmpty());
assertEquals(3, map.size());
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testDescendingEquals.
/**
* Maps with same contents are equal
*/
public void testDescendingEquals() {
NavigableMap map1 = dmap5();
NavigableMap map2 = dmap5();
assertEquals(map1, map2);
assertEquals(map2, map1);
map1.clear();
assertFalse(map1.equals(map2));
assertFalse(map2.equals(map1));
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testEntrySet.
/**
* entrySet contains all pairs
*/
public void testEntrySet() {
NavigableMap map = map5();
Set s = map.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.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testFirstKey.
/**
* firstKey returns first key
*/
public void testFirstKey() {
NavigableMap map = map5();
assertEquals(one, map.firstKey());
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testDescendingToString.
/**
* toString contains toString of elements
*/
public void testDescendingToString() {
NavigableMap map = dmap5();
String s = map.toString();
for (int i = 1; i <= 5; ++i) {
assertTrue(s.contains(String.valueOf(i)));
}
}
Aggregations