toHaveElementsAndNone
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndNone(assertionCreatorOrNull: Expect<E>.() -> Unit?): Expect<T>(source)
Expects that the subject of this
expectation (an Iterable) has at least one element and that it either does not contain a single entry which holds all assertions created by assertionCreatorOrNull or that it does not contain a single entry which is null
in case assertionCreatorOrNull is defined as null
.
It is a shortcut for notToContain o entry assertionCreatorOrNull
Return
an Expect for the subject of this
expectation.
Since
0.17.0
Samples
expect(listOf(1, 2, 2, 4)) toHaveElementsAndNone { it toEqual 3 }
expect(listOf<Int?>(1, 2, 2, 4)) toHaveElementsAndNone null
fails {
expect(emptyList<Int>()) toHaveElementsAndNone { it toEqual 11 }
}
fails {
expect(listOf(1, 2, 2, 4)) toHaveElementsAndNone {
it toBeLessThanOrEqualTo 1
}
}