| 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('Reports mismatches in whitespace and escape sequences', () { |
| 16 shouldFail('before\nafter', equals('before\\nafter'), |
| 17 contains('Differ at offset 7')); |
| 18 }); |
| 19 |
| 15 test('collapseWhitespace', () { | 20 test('collapseWhitespace', () { |
| 16 var source = '\t\r\n hello\t\r\n world\r\t \n'; | 21 var source = '\t\r\n hello\t\r\n world\r\t \n'; |
| 17 expect(collapseWhitespace(source), 'hello world'); | 22 expect(collapseWhitespace(source), 'hello world'); |
| 18 }); | 23 }); |
| 19 | 24 |
| 20 test('isEmpty', () { | 25 test('isEmpty', () { |
| 21 shouldPass('', isEmpty); | 26 shouldPass('', isEmpty); |
| 22 shouldFail(null, isEmpty, startsWith("Expected: empty Actual: <null>")); | 27 shouldFail(null, isEmpty, startsWith("Expected: empty Actual: <null>")); |
| 23 shouldFail(0, isEmpty, startsWith("Expected: empty Actual: <0>")); | 28 shouldFail(0, isEmpty, startsWith("Expected: empty Actual: <0>")); |
| 24 shouldFail('a', isEmpty, startsWith("Expected: empty Actual: 'a'")); | 29 shouldFail('a', isEmpty, startsWith("Expected: empty Actual: 'a'")); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 "Actual: 'goodbye cruel world'"); | 106 "Actual: 'goodbye cruel world'"); |
| 102 }); | 107 }); |
| 103 | 108 |
| 104 test('matches', () { | 109 test('matches', () { |
| 105 shouldPass('c0d', matches('[a-z][0-9][a-z]')); | 110 shouldPass('c0d', matches('[a-z][0-9][a-z]')); |
| 106 shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]'))); | 111 shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]'))); |
| 107 shouldFail('cOd', matches('[a-z][0-9][a-z]'), | 112 shouldFail('cOd', matches('[a-z][0-9][a-z]'), |
| 108 "Expected: match '[a-z][0-9][a-z]' Actual: 'cOd'"); | 113 "Expected: match '[a-z][0-9][a-z]' Actual: 'cOd'"); |
| 109 }); | 114 }); |
| 110 } | 115 } |
| OLD | NEW |