haveLength method

StringAssertions haveLength(
  1. int expected
)

Asserts that a string has the specified expected length. expected The expected length of the string

Implementation

StringAssertions haveLength(int expected) {
  if (isReversed) {
    if (subject!.length == expected) {
      throw ShouldlyTestFailureError(
        "String length of '$subject' is $expected chars",
      );
    }
    return StringAssertions(subject, isReversed: isReversed);
  }

  if (subject!.length != expected) {
    throw ShouldlyTestFailureError(
      'String length of `$subject` is not $expected chars',
    );
  }

  return StringAssertions(subject, isReversed: isReversed);
}