doc / ch.tutteli.atrium.api.infix.en_GB / all

all

infix fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> (source)
Deprecated: Use toHaveElementsAndAll; will be removed with 1.0.0 at the latest

Expects that the subject of this expectation (an Iterable) has at least one element and that either every element holds all assertions created by the assertionCreatorOrNull or that all elements are null in case assertionCreatorOrNull is defined as null.

Return
an Expect for the subject of this expectation.

fun <T> all(t: T, vararg ts: T): All<T> (source)

Helper function to create an All based on the given t and ts -- allows expressing T, vararg T.

// all regex patterns match
expect("ABC") toContain all("A".toRegex(), "B".toRegex())

// holds because `toContain all(...)` does not search for unique matches
// use `toContain exactly 2 regex regex` to check if the subject contains the regex two times
val regex = "A(B)?".toRegex()
expect("ABC") toContain all(regex, regex)

fails { // because second regex doesn't match
    expect("ABC") toContain all("A".toRegex(), "X".toRegex())
}