expectIterable<T> function
void
expectIterable<T>(})
Expect that actual has the same length as matcher and
that they have the same elements, as per baseEquality.
If checkOrder is true, then the order of the elements matters as well.
Implementation
void expectIterable<T>(
Iterable<T>? actual,
Iterable<T>? matcher, {
bool checkOrder = true,
dynamic skip,
Equality<T>? baseEquality,
}) {
expect(
actual?.length,
matcher?.length,
reason: "Not the same length",
);
final theEquality = checkOrder
? DeepCollectionEquality(baseEquality ?? DefaultEquality<T>())
: DeepCollectionEquality.unordered(baseEquality ?? DefaultEquality<T>());
var reason = "The iterables do not have the same elements";
if (checkOrder) {
reason += " in the same order";
}
expectTrue(
theEquality.equals(actual, matcher),
skip: skip,
reason: reason,
);
}