toHaveElementsAndAny
fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndAny(assertionCreatorOrNull: Expect<E>.() -> Unit?): Expect<T>(source)
Expects that the subject of this expectation (an Iterable) has next element(s) and
that any of them holds the expectations the assertionCreatorOrNull creates or
that any of them is
nullin case assertionCreatorOrNull is defined asnull.
It is logically equivalent to toContain.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)
Return
an Expect for the subject of this expectation.
Since
0.17.0
Samples
expect(listOf(1, 2, 2, 4)).toHaveElementsAndAny {
toBeGreaterThan(1)
toBeLessThan(3)
}
expect(listOf(null, 2, 3)).toHaveElementsAndAny(null)
fails {
expect(emptyList<Int>()).toHaveElementsAndAny { toBeLessThan(11) }
}
fails {
expect(listOf(1, 2, 2, 4)).toHaveElementsAndAny {
toBeGreaterThan(5)
}
}