use of org.neo4j.collection.primitive.PrimitiveLongVisitor in project neo4j by neo4j.
the class PrimitiveLongSetTest method shouldContainAddedValues_generated_1.
@Test
public void shouldContainAddedValues_generated_1() throws Exception {
// GIVEN
PrimitiveLongSet set = newSet(15);
Set<Long> expectedValues = new HashSet<>();
long[] valuesToAdd = new long[] { 1207043189, 380713862, 1902858197, 1996873101, 1357024628, 1044248801, 1558157493, 2040311008, 2017660098, 1332670047, 663662790, 2063747422, 1554358949, 1761477445, 1141526838, 1698679618, 1279767067, 508574, 2071755904 };
for (long key : valuesToAdd) {
set.add(key);
expectedValues.add(key);
}
// WHEN/THEN
boolean existedBefore = set.contains(679990875);
boolean added = set.add(679990875);
boolean existsAfter = set.contains(679990875);
assertFalse("679990875 should not exist before adding here", existedBefore);
assertTrue("679990875 should be reported as added here", added);
assertTrue("679990875 should exist", existsAfter);
expectedValues.add(679990875L);
final Set<Long> visitedKeys = new HashSet<>();
set.visitKeys(new PrimitiveLongVisitor() {
@Override
public boolean visited(long value) {
assertTrue(visitedKeys.add(value));
return false;
}
});
assertEquals(expectedValues, visitedKeys);
}
Aggregations