containsAll function
- Iterable expected
Matches Iterables which contain an element matching every value in
expected
in any order, and may contain additional values.
For example: [0, 1, 0, 2, 0]
matches containsAll([1, 2])
and
containsAll([2, 1])
but not containsAll([1, 2, 3])
.
Will only match values which implement Iterable.
Each element in the value will only be considered a match for a single
matcher in expected
even if it could satisfy more than one. For instance
containsAll([greaterThan(1), greaterThan(2)])
will not be satisfied by
[3]
. To check that all matchers are satisfied within an iterable and allow
the same element to satisfy multiple matchers use
allOf(matchers.map(contains))
.
Note that this is worst case O(n^2) runtime and memory usage so it should only be used on small iterables.
Implementation
Matcher containsAll(Iterable expected) => _ContainsAll(expected);