use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeMapTest method testSerialization.
/**
* A deserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
NavigableMap y = serialClone(x);
assertNotSame(x, y);
assertEquals(x.size(), y.size());
assertEquals(x.toString(), y.toString());
assertEquals(x, y);
assertEquals(y, x);
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testHigherEntry.
/**
* higherEntry returns next entry.
*/
public void testHigherEntry() {
NavigableMap map = map5();
Map.Entry e1 = map.higherEntry(three);
assertEquals(four, e1.getKey());
Map.Entry e2 = map.higherEntry(zero);
assertEquals(one, e2.getKey());
Map.Entry e3 = map.higherEntry(five);
assertNull(e3);
Map.Entry e4 = map.higherEntry(six);
assertNull(e4);
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testToString.
/**
* toString contains toString of elements
*/
public void testToString() {
NavigableMap map = map5();
String s = map.toString();
for (int i = 1; i <= 5; ++i) {
assertTrue(s.contains(String.valueOf(i)));
}
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testTailMapContents.
/**
* headMap returns map with keys in requested range
*/
public void testTailMapContents() {
NavigableMap map = map5();
SortedMap sm = map.tailMap(two);
assertFalse(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertTrue(sm.containsKey(four));
assertTrue(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer) (i.next());
assertEquals(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
k = (Integer) (i.next());
assertEquals(four, k);
k = (Integer) (i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
Iterator ei = sm.entrySet().iterator();
Map.Entry e;
e = (Map.Entry) (ei.next());
assertEquals(two, e.getKey());
assertEquals("B", e.getValue());
e = (Map.Entry) (ei.next());
assertEquals(three, e.getKey());
assertEquals("C", e.getValue());
e = (Map.Entry) (ei.next());
assertEquals(four, e.getKey());
assertEquals("D", e.getValue());
e = (Map.Entry) (ei.next());
assertEquals(five, e.getKey());
assertEquals("E", e.getValue());
assertFalse(i.hasNext());
SortedMap ssm = sm.tailMap(four);
assertEquals(four, ssm.firstKey());
assertEquals(five, ssm.lastKey());
assertEquals("D", ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, map.size());
}
use of java.util.NavigableMap in project mapdb by jankotek.
the class TreeSubMapTest method testDescendingIsEmpty.
/**
* isEmpty is true of empty map and false for non-empty
*/
public void testDescendingIsEmpty() {
NavigableMap empty = dmap0();
NavigableMap map = dmap5();
assertTrue(empty.isEmpty());
assertFalse(map.isEmpty());
}
Aggregations