expectMap<K, V> function

void expectMap<K, V>(
  1. Map<K, V>? actual,
  2. Map<K, V>? matcher, {
  3. dynamic skip,
  4. Equality<K>? keyEquality,
  5. Equality<V>? valueEquality,
})

Expect that actual has the same length as matcher and that they have the same entries, as per keyEquality and valueEquality.

Implementation

void expectMap<K, V>(
  Map<K, V>? actual,
  Map<K, V>? matcher, {
  dynamic skip, // true or a String
  Equality<K>? keyEquality,
  Equality<V>? valueEquality,
}) {
  expect(
    actual?.length,
    matcher?.length,
    reason: "Not the same length",
  );

  final theEquality = MapEquality<K, V>(
    keys: keyEquality ?? DefaultEquality<K>(),
    values: valueEquality ?? DefaultEquality<V>(),
  );

  expectTrue(
    theEquality.equals(actual, matcher),
    skip: skip,
    reason: "The maps do not have the same entries.",
  );
}