inline infix fun <reified E, T : Iterable<E>> Expect<T>.toContainExactlyElementsOf(expectedIterableLike: IterableLike): Expect<T>
(source)
Expects that the subject of this
expectation (an Iterable) contains only elements of expectedIterableLike
in same order
It is a shortcut for 'toContain o inGiven order and only elementsOf expectedIterableLike'
Notice that a runtime check applies which assures that only Iterable, Sequence or one of the Array types are passed. This function expects IterableLike (which is a typealias for Any) to avoid cluttering the API.
expect(listOf(1, 2, 2, 4)) toContainExactlyElementsOf listOf(1, 2, 2, 4)
fails {
expect(listOf(2, 3, 4)) toContainExactlyElementsOf listOf(2, 3, 4, 1)
}
fails {
expect(listOf(1, 2, 2, 4)) toContainExactlyElementsOf listOf(1, 2, 4)
}
fails {
// alternative form where you can specify a lambda configuring the InOrderOnlyReportingOptions.
expect(listOf(1, 2, 2, 4)) toContainExactly elementsOf(
listOf(1, 2, 4),
reportOptionsInOrderOnly = { // allows configuring reporting, e.g.
showOnlyFailing() // would not show the successful first and second `1, 2`
showOnlyFailingIfMoreExpectedElementsThan(10)
}
)
}
IllegalArgumentException
- in case expectedIterableLike is not an Iterable, Sequence or one of the Array types
or the given expectedIterableLike does not have elements (is empty).
Return
an Expect for the subject of this
expectation.
Since
0.17.0