| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 test.services.correction.strings; | 5 library test.services.correction.strings; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/correction/strings.dart'; | 7 import 'package:analysis_server/src/services/correction/strings.dart'; |
| 8 import 'package:test/test.dart' hide isEmpty; |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 9 import 'package:unittest/unittest.dart' hide isEmpty; | |
| 10 | 10 |
| 11 import '../../utils.dart'; | 11 import '../../utils.dart'; |
| 12 | 12 |
| 13 main() { | 13 main() { |
| 14 initializeTestEnvironment(); | 14 initializeTestEnvironment(); |
| 15 defineReflectiveTests(StringsTest); | 15 defineReflectiveSuite(() { |
| 16 defineReflectiveTests(StringsTest); |
| 17 }); |
| 16 } | 18 } |
| 17 | 19 |
| 18 @reflectiveTest | 20 @reflectiveTest |
| 19 class StringsTest { | 21 class StringsTest { |
| 20 void test_capitalize() { | 22 void test_capitalize() { |
| 21 expect(capitalize(''), ''); | 23 expect(capitalize(''), ''); |
| 22 expect(capitalize('a'), 'A'); | 24 expect(capitalize('a'), 'A'); |
| 23 expect(capitalize('abc'), 'Abc'); | 25 expect(capitalize('abc'), 'Abc'); |
| 24 expect(capitalize('abc def'), 'Abc def'); | 26 expect(capitalize('abc def'), 'Abc def'); |
| 25 expect(capitalize('ABC'), 'ABC'); | 27 expect(capitalize('ABC'), 'ABC'); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 void test_computeSimpleDiff() { | 38 void test_computeSimpleDiff() { |
| 37 assertDiff(String oldStr, String newStr) { | 39 assertDiff(String oldStr, String newStr) { |
| 38 SimpleDiff diff = computeSimpleDiff(oldStr, newStr); | 40 SimpleDiff diff = computeSimpleDiff(oldStr, newStr); |
| 39 expect(diff.offset, isNonNegative); | 41 expect(diff.offset, isNonNegative); |
| 40 expect(diff.length, isNonNegative); | 42 expect(diff.length, isNonNegative); |
| 41 String applied = oldStr.substring(0, diff.offset) + | 43 String applied = oldStr.substring(0, diff.offset) + |
| 42 diff.replacement + | 44 diff.replacement + |
| 43 oldStr.substring(diff.offset + diff.length); | 45 oldStr.substring(diff.offset + diff.length); |
| 44 expect(applied, newStr); | 46 expect(applied, newStr); |
| 45 } | 47 } |
| 48 |
| 46 assertDiff('', ''); | 49 assertDiff('', ''); |
| 47 assertDiff('', 'a'); | 50 assertDiff('', 'a'); |
| 48 assertDiff('abc', ''); | 51 assertDiff('abc', ''); |
| 49 assertDiff('abcd', 'acd'); | 52 assertDiff('abcd', 'acd'); |
| 50 assertDiff('a', 'b'); | 53 assertDiff('a', 'b'); |
| 51 assertDiff('12345xyz', '12345abcxyz'); | 54 assertDiff('12345xyz', '12345abcxyz'); |
| 52 assertDiff('12345xyz', '12345xyzabc'); | 55 assertDiff('12345xyz', '12345xyzabc'); |
| 53 assertDiff('abbc', 'abbbc'); | 56 assertDiff('abbc', 'abbbc'); |
| 54 assertDiff('abbbbc', 'abbbbbbc'); | 57 assertDiff('abbbbc', 'abbbbbbc'); |
| 55 } | 58 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 expect(repeat('abc', 3), 'abcabcabc'); | 202 expect(repeat('abc', 3), 'abcabcabc'); |
| 200 } | 203 } |
| 201 | 204 |
| 202 void test_substringAfterLast() { | 205 void test_substringAfterLast() { |
| 203 expect(substringAfterLast('', '/'), ''); | 206 expect(substringAfterLast('', '/'), ''); |
| 204 expect(substringAfterLast('abc', ''), ''); | 207 expect(substringAfterLast('abc', ''), ''); |
| 205 expect(substringAfterLast('abc', 'd'), 'abc'); | 208 expect(substringAfterLast('abc', 'd'), 'abc'); |
| 206 expect(substringAfterLast('abcbde', 'b'), 'de'); | 209 expect(substringAfterLast('abcbde', 'b'), 'de'); |
| 207 } | 210 } |
| 208 } | 211 } |
| OLD | NEW |