notToHave

infix fun <E, T : Iterable<E>> Expect<T>.notToHave(elements: elements): Expect<T>(source)

Expects that the subject of this expectation (an Iterable) does not have next element.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(setOf<String>()) notToHave elements

fails {
    expect(listOf("A", "B")) notToHave elements
}

infix fun <T : Iterator<*>> Expect<T>.notToHave(next: next): Expect<T>(source)

Expects that the subject of this expectation (an Iterator) does not have next element.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

val list = listOf(1)
val iterator = list.iterator()

fails {
    expect(iterator) notToHave next  // fails as iterator has a next element (has actually one element)
}

iterator.next()                      // returns the next element in iteration
expect(iterator) notToHave next      // list has no more elements thus expectation holds