doc / ch.tutteli.atrium.api.fluent.en_GB / toHaveNext

toHaveNext

fun <T : Iterator<*>> Expect<T>.toHaveNext(): Expect<T> (source)

Expects that the subject of this expectation (an Iterator) has a next element.

val iterator = listOf(1).iterator()

expect(iterator).toHaveNext()      // holds as iterator has a next element

fails {
    iterator.next()                // returns the next element in iteration
    expect(iterator).toHaveNext()  // fails as list has only 1 element, i.e. no next any more.
}

Return
an Expect for the subject of this expectation.

Since
0.17.0