| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library matcher.string_matchers_test; | 5 library matcher.string_matchers_test; |
| 6 | 6 |
| 7 import 'package:matcher/matcher.dart'; | 7 import 'package:matcher/matcher.dart'; |
| 8 import 'package:unittest/unittest.dart' show test, group; | 8 import 'package:unittest/unittest.dart' show test, group; |
| 9 | 9 |
| 10 import 'test_utils.dart'; | 10 import 'test_utils.dart'; |
| 11 | 11 |
| 12 void main() { | 12 void main() { |
| 13 initUtils(); | 13 initUtils(); |
| 14 | 14 |
| 15 test('collapseWhitespace', () { | 15 test('collapseWhitespace', () { |
| 16 var source = '\t\r\n hello\t\r\n world\r\t \n'; | 16 var source = '\t\r\n hello\t\r\n world\r\t \n'; |
| 17 expect(collapseWhitespace(source), 'hello world'); | 17 expect(collapseWhitespace(source), 'hello world'); |
| 18 }); | 18 }); |
| 19 | 19 |
| 20 test('isEmpty', () { | 20 test('isEmpty', () { |
| 21 shouldPass('', isEmpty); | 21 shouldPass('', isEmpty); |
| 22 shouldFail(null, isEmpty, "Expected: empty Actual: <null>"); | 22 shouldFail(null, isEmpty, "Expected: empty Actual: <null>"); |
| 23 shouldFail(0, isEmpty, "Expected: empty Actual: <0>"); | 23 shouldFail(0, isEmpty, "Expected: empty Actual: <0>"); |
| 24 shouldFail('a', isEmpty, "Expected: empty Actual: 'a'"); | 24 shouldFail('a', isEmpty, "Expected: empty Actual: 'a'"); |
| 25 }); | 25 }); |
| 26 | 26 |
| 27 test('isNotEmpty', () { |
| 28 shouldFail('', isNotEmpty, "Expected: non-empty Actual: ''"); |
| 29 shouldFail(null, isNotEmpty, "Expected: non-empty Actual: <null>"); |
| 30 shouldFail(0, isNotEmpty, "Expected: non-empty Actual: <0>"); |
| 31 shouldPass('a', isNotEmpty); |
| 32 }); |
| 33 |
| 27 test('equalsIgnoringCase', () { | 34 test('equalsIgnoringCase', () { |
| 28 shouldPass('hello', equalsIgnoringCase('HELLO')); | 35 shouldPass('hello', equalsIgnoringCase('HELLO')); |
| 29 shouldFail('hi', equalsIgnoringCase('HELLO'), | 36 shouldFail('hi', equalsIgnoringCase('HELLO'), |
| 30 "Expected: 'HELLO' ignoring case Actual: 'hi'"); | 37 "Expected: 'HELLO' ignoring case Actual: 'hi'"); |
| 31 }); | 38 }); |
| 32 | 39 |
| 33 test('equalsIgnoringWhitespace', () { | 40 test('equalsIgnoringWhitespace', () { |
| 34 shouldPass(' hello world ', equalsIgnoringWhitespace('hello world')); | 41 shouldPass(' hello world ', equalsIgnoringWhitespace('hello world')); |
| 35 shouldFail(' helloworld ', equalsIgnoringWhitespace('hello world'), | 42 shouldFail(' helloworld ', equalsIgnoringWhitespace('hello world'), |
| 36 "Expected: 'hello world' ignoring whitespace " | 43 "Expected: 'hello world' ignoring whitespace " |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 "Actual: 'goodbye cruel world'"); | 92 "Actual: 'goodbye cruel world'"); |
| 86 }); | 93 }); |
| 87 | 94 |
| 88 test('matches', () { | 95 test('matches', () { |
| 89 shouldPass('c0d', matches('[a-z][0-9][a-z]')); | 96 shouldPass('c0d', matches('[a-z][0-9][a-z]')); |
| 90 shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]'))); | 97 shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]'))); |
| 91 shouldFail('cOd', matches('[a-z][0-9][a-z]'), | 98 shouldFail('cOd', matches('[a-z][0-9][a-z]'), |
| 92 "Expected: match '[a-z][0-9][a-z]' Actual: 'cOd'"); | 99 "Expected: match '[a-z][0-9][a-z]' Actual: 'cOd'"); |
| 93 }); | 100 }); |
| 94 } | 101 } |
| OLD | NEW |