verify function

bool verify(
  1. bool condition,
  2. String errorMessage
)

Verify that a condition is true.

If condition is false, records a verification failure with errorMessage. In test mode, failures are collected and reported at the end. In normal mode, prints an error message.

Example:

verify(count > 0, 'Count should be positive');
verify(result == expected, 'Result $result did not match expected $expected');

Returns true if the verification passed, false otherwise.

Implementation

bool verify(bool condition, String errorMessage) {
  if (!condition) {
    _verificationFailures.add(errorMessage);
    return false;
  }
  return true;
}