use of org.eclipse.collections.api.tuple.primitive.ObjectLongPair in project neo4j by neo4j.
the class AppendOnlyValuesContainerTest method randomizedTest.
@Test
void randomizedTest() {
final int count = 10000 + rnd.nextInt(1000);
final List<ObjectLongPair<Value>> valueRefPairs = new ArrayList<>();
final MutableList<ObjectLongPair<Value>> toRemove = new FastList<>();
for (int i = 0; i < count; i++) {
final Value value = rnd.randomValues().nextValue();
final long ref = container.add(value);
final ObjectLongPair<Value> pair = pair(value, ref);
if (rnd.nextBoolean()) {
toRemove.add(pair);
} else {
valueRefPairs.add(pair);
}
}
toRemove.shuffleThis(rnd.random());
for (final ObjectLongPair<Value> valueRefPair : toRemove) {
final Value removed = container.remove(valueRefPair.getTwo());
assertEquals(valueRefPair.getOne(), removed);
assertThrows(IllegalArgumentException.class, () -> container.remove(valueRefPair.getTwo()));
assertThrows(IllegalArgumentException.class, () -> container.get(valueRefPair.getTwo()));
}
for (final ObjectLongPair<Value> valueRefPair : valueRefPairs) {
final Value actualValue = container.get(valueRefPair.getTwo());
assertEquals(valueRefPair.getOne(), actualValue);
}
}
Aggregations