use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testIterator.
/**
* iterator iterates through all elements
*/
public void testIterator() {
NavigableSet q = populatedSet(SIZE);
Iterator it = q.iterator();
int i;
for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next()));
assertEquals(i, SIZE);
assertIteratorExhausted(it);
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testContainsAll.
/**
* containsAll(c) is true when c contains a subset of elements
*/
public void testContainsAll() {
NavigableSet q = populatedSet(SIZE);
NavigableSet p = set0();
for (int i = 0; i < SIZE; ++i) {
assertTrue(q.containsAll(p));
assertFalse(p.containsAll(q));
p.add(new Integer(i));
}
assertTrue(p.containsAll(q));
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testDescendingSerialization.
/**
* A deserialized serialized set has same elements
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();
NavigableSet y = serialClone(x);
assertNotSame(x, y);
assertEquals(x.size(), y.size());
assertEquals(x.toString(), y.toString());
assertEquals(x, y);
assertEquals(y, x);
while (!x.isEmpty()) {
assertFalse(y.isEmpty());
assertEquals(x.pollFirst(), y.pollFirst());
}
assertTrue(y.isEmpty());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testAddAll3.
/**
* addAll of a collection with any null elements throws NPE after
* possibly adding some elements
*/
public void testAddAll3() {
NavigableSet q = set0();
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE - 1; ++i) ints[i] = new Integer(i + SIZE);
try {
q.addAll(Arrays.asList(ints));
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testDescendingTailSetContents.
/**
* tailSet returns set with keys in requested range
*/
public void testDescendingTailSetContents() {
NavigableSet set = dset5();
SortedSet sm = set.tailSet(m2);
assertFalse(sm.contains(m1));
assertTrue(sm.contains(m2));
assertTrue(sm.contains(m3));
assertTrue(sm.contains(m4));
assertTrue(sm.contains(m5));
Iterator i = sm.iterator();
Object k;
k = (Integer) (i.next());
assertEquals(m2, k);
k = (Integer) (i.next());
assertEquals(m3, k);
k = (Integer) (i.next());
assertEquals(m4, k);
k = (Integer) (i.next());
assertEquals(m5, k);
assertFalse(i.hasNext());
SortedSet ssm = sm.tailSet(m4);
assertEquals(m4, ssm.first());
assertEquals(m5, ssm.last());
assertTrue(ssm.remove(m4));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
Aggregations