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

toHaveElementsAndAny

infix 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) contains an entry holding the assertions created by assertionCreatorOrNull or an entry which is null in case assertionCreatorOrNull is defined as null.

It is a shortcut for toContain o inAny order atLeast 1 entry assertionCreatorOrNull

expect(listOf(1, 2, 2, 4)) toHaveElementsAndAny {
    toBeGreaterThan(1)
    toBeLessThan(3)
}

fails {
    expect(emptyList<Int>()) toHaveElementsAndAny { toBeLessThan(11) }
}

fails {
    expect(listOf(1, 2, 2, 4)) toHaveElementsAndAny {
        toBeGreaterThan(5)
    }
}

Return
an Expect for the subject of this expectation.

Since
0.17.0