expectIterable<T> function

void expectIterable<T>(
  1. Iterable<T>? actual,
  2. Iterable<T>? matcher, {
  3. bool checkOrder = true,
  4. dynamic skip,
  5. Equality<T>? baseEquality,
})

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,
  );
}