CockpitTestMatrix constructor

CockpitTestMatrix({
  1. Map<String, List<Object?>> axes = const <String, List<Object?>>{},
  2. Iterable<Map<String, Object?>> include = const <Map<String, Object?>>[],
  3. Iterable<Map<String, Object?>> exclude = const <Map<String, Object?>>[],
  4. int maxCombinations = 256,
})

Creates a CockpitTestMatrix.

Implementation

CockpitTestMatrix({
  Map<String, List<Object?>> axes = const <String, List<Object?>>{},
  Iterable<Map<String, Object?>> include = const <Map<String, Object?>>[],
  Iterable<Map<String, Object?>> exclude = const <Map<String, Object?>>[],
  this.maxCombinations = 256,
}) : axes = _axes(axes),
     include = _rows(include, r'$.include'),
     exclude = _rows(exclude, r'$.exclude') {
  if (maxCombinations < 1 || maxCombinations > 4096) {
    throw const FormatException(
      'Matrix maxCombinations must be between 1 and 4096.',
    );
  }
  _validateRows(this.include, r'$.include');
  _validateRows(this.exclude, r'$.exclude');
  var product = this.axes.isEmpty ? 1 : 1;
  for (final values in this.axes.values) {
    product *= values.length;
    if (product > maxCombinations) {
      throw const FormatException(
        'Matrix cartesian product exceeds its bound.',
      );
    }
  }
  if (product + this.include.length > maxCombinations) {
    throw const FormatException('Matrix expansion exceeds its bound.');
  }
}