notToHaveElementsOrNone

fun <E : Any, T : Iterable<E?>> Expect<T>.notToHaveElementsOrNone(assertionCreatorOrNull: Expect<E>.() -> Unit?): Expect<T>(source)

Expects that the subject of this expectation (an Iterable) either has no next element or

Return

an Expect for the subject of this expectation.

Since

1.0.0

Samples

// passes as the list is empty
expect(emptyList<Int>()).notToHaveElementsOrNone { toBeGreaterThan(1) }

// passes as no element fulfills the sub expectation
expect(listOf(2, 3, 4)).notToHaveElementsOrNone { toBeGreaterThan(4) }
expect(listOf<Int?>(2, 3, 4)).notToHaveElementsOrNone(null)

fails {
    expect(listOf(1, 2, 2, 4)).notToHaveElementsOrNone {
        toBeLessThanOrEqualTo(1)
    }
}