blob: 72e0e6a28a09a0f6d340423d69ab659d830b02b3 [file]
import 'package:matcher/expect.dart';
import 'package:test/scaffolding.dart';
void main() {
test('equalsIgnoringWhitespace', () {
// Runs of whitespace are collapsed to a single space, and leading and
// trailing whitespace is removed, before the two strings are compared.
expect('hello world', equalsIgnoringWhitespace('hello world'));
expect(' hello world', equalsIgnoringWhitespace('hello world'));
expect('hello world ', equalsIgnoringWhitespace('hello world'));
// Tabs and newlines are whitespace as well as spaces.
expect('hello\tworld', equalsIgnoringWhitespace('hello world'));
expect('''
hello
world
''', equalsIgnoringWhitespace('hello world'));
});
test('equalsIgnoringWhitespace when the text differs', () {
expect('hello wide world', equalsIgnoringWhitespace('hello world'));
// Expected: 'hello world' ignoring whitespace
// Actual: 'hello wide world'
// Which: is 'hello wide world' with whitespace compressed
});
test('equalsIgnoringWhitespace when whitespace is missing', () {
// Whitespace is collapsed, never removed, so a missing space does not
// match.
expect('helloworld', equalsIgnoringWhitespace('hello world'));
// Expected: 'hello world' ignoring whitespace
// Actual: 'helloworld'
// Which: is 'helloworld' with whitespace compressed
});
}