use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testTailSetContents.
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
NavigableSet set = set5();
SortedSet sm = set.tailSet(two);
assertFalse(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertTrue(sm.contains(four));
assertTrue(sm.contains(five));
Iterator i = sm.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());
SortedSet ssm = sm.tailSet(four);
assertEquals(four, ssm.first());
assertEquals(five, ssm.last());
assertTrue(ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingContainsAll.
/**
* containsAll(c) is true when c contains a subset of elements
*/
public void testDescendingContainsAll() {
NavigableSet q = populatedSet(SIZE);
NavigableSet p = dset0();
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 ConcurrentSkipListSubSetTest method testDescendingSerialization.
/**
* A deserialized serialized set has same elements
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();
NavigableSet y = serialClone(x);
assertNotSame(y, x);
assertEquals(x.size(), y.size());
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 ConcurrentSkipListSubSetTest 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 ConcurrentSkipListSubSetTest method testDescendingToArray2.
/**
* toArray(a) contains all elements
*/
public void testDescendingToArray2() {
NavigableSet q = populatedSet(SIZE);
Integer[] ints = new Integer[SIZE];
assertSame(ints, q.toArray(ints));
Arrays.sort(ints);
for (int i = 0; i < ints.length; i++) assertEquals(ints[i], q.pollFirst());
}
Aggregations