use of org.neo4j.collection.PrimitiveLongCollections.AbstractPrimitiveLongBaseIterator in project neo4j by neo4j.
the class PrimitiveLongCollectionsTest method shouldNotContinueToCallNextOnHasNextFalse.
@Test
void shouldNotContinueToCallNextOnHasNextFalse() {
// GIVEN
AtomicLong count = new AtomicLong(2);
LongIterator iterator = new AbstractPrimitiveLongBaseIterator() {
@Override
protected boolean fetchNext() {
return count.decrementAndGet() >= 0 && next(count.get());
}
};
// WHEN/THEN
assertTrue(iterator.hasNext());
assertTrue(iterator.hasNext());
assertEquals(1L, iterator.next());
assertTrue(iterator.hasNext());
assertTrue(iterator.hasNext());
assertEquals(0L, iterator.next());
assertFalse(iterator.hasNext());
assertFalse(iterator.hasNext());
assertEquals(-1L, count.get());
}
Aggregations