use of org.neo4j.collection.primitive.PrimitiveLongCollections.PrimitiveLongBaseIterator in project neo4j by neo4j.
the class PrimitiveLongCollectionsTest method shouldNotContinueToCallNextOnHasNextFalse.
@Test
public void shouldNotContinueToCallNextOnHasNextFalse() throws Exception {
// GIVEN
AtomicLong count = new AtomicLong(2);
PrimitiveLongIterator iterator = new PrimitiveLongBaseIterator() {
@Override
protected boolean fetchNext() {
return count.decrementAndGet() >= 0 ? next(count.get()) : false;
}
};
// 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