| 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_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 9 import 'package:unittest/unittest.dart' hide isEmpty; | 9 import 'package:unittest/unittest.dart' hide isEmpty; |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 void test_compareStrings() { | 28 void test_compareStrings() { |
| 29 expect(compareStrings(null, null), 0); | 29 expect(compareStrings(null, null), 0); |
| 30 expect(compareStrings(null, 'b'), 1); | 30 expect(compareStrings(null, 'b'), 1); |
| 31 expect(compareStrings('a', null), -1); | 31 expect(compareStrings('a', null), -1); |
| 32 expect(compareStrings('a', 'b'), -1); | 32 expect(compareStrings('a', 'b'), -1); |
| 33 expect(compareStrings('b', 'a'), 1); | 33 expect(compareStrings('b', 'a'), 1); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void test_countMatches() { |
| 37 expect(countMatches(null, null), 0); |
| 38 expect(countMatches('abc', null), 0); |
| 39 expect(countMatches(null, 'abc'), 0); |
| 40 expect(countMatches('ababa', 'a'), 3); |
| 41 expect(countMatches('ababa', 'ab'), 2); |
| 42 expect(countMatches('aaabaa', 'aa'), 2); |
| 43 } |
| 44 |
| 36 void test_findCommonOverlap() { | 45 void test_findCommonOverlap() { |
| 37 expect(findCommonOverlap('', 'abcd'), 0); | 46 expect(findCommonOverlap('', 'abcd'), 0); |
| 38 expect(findCommonOverlap('abc', 'abcd'), 3); | 47 expect(findCommonOverlap('abc', 'abcd'), 3); |
| 39 expect(findCommonOverlap('123456', 'abcd'), 0); | 48 expect(findCommonOverlap('123456', 'abcd'), 0); |
| 40 expect(findCommonOverlap('123456xxx', 'xxxabcd'), 3); | 49 expect(findCommonOverlap('123456xxx', 'xxxabcd'), 3); |
| 41 expect(findCommonOverlap('123456', '56'), 2); | 50 expect(findCommonOverlap('123456', '56'), 2); |
| 42 expect(findCommonOverlap('56', '56789'), 2); | 51 expect(findCommonOverlap('56', '56789'), 2); |
| 43 } | 52 } |
| 44 | 53 |
| 45 void test_findCommonPrefix() { | 54 void test_findCommonPrefix() { |
| 46 expect(findCommonPrefix('abc', 'xyz'), 0); | 55 expect(findCommonPrefix('abc', 'xyz'), 0); |
| 47 expect(findCommonPrefix('1234abcdef', '1234xyz'), 4); | 56 expect(findCommonPrefix('1234abcdef', '1234xyz'), 4); |
| 48 expect(findCommonPrefix('123', '123xyz'), 3); | 57 expect(findCommonPrefix('123', '123xyz'), 3); |
| 49 } | 58 } |
| 50 | 59 |
| 51 void test_findCommonSuffix() { | 60 void test_findCommonSuffix() { |
| 52 expect(findCommonSuffix('abc', 'xyz'), 0); | 61 expect(findCommonSuffix('abc', 'xyz'), 0); |
| 53 expect(findCommonSuffix('abcdef1234', 'xyz1234'), 4); | 62 expect(findCommonSuffix('abcdef1234', 'xyz1234'), 4); |
| 54 expect(findCommonSuffix('123', 'xyz123'), 3); | 63 expect(findCommonSuffix('123', 'xyz123'), 3); |
| 55 } | 64 } |
| 56 | 65 |
| 66 void test_getCamelWords() { |
| 67 expect(getCamelWords(null), []); |
| 68 expect(getCamelWords(''), []); |
| 69 expect(getCamelWords('getCamelWords'), ['get', 'Camel', 'Words']); |
| 70 expect(getCamelWords('getHTMLText'), ['get', 'HTML', 'Text']); |
| 71 } |
| 72 |
| 57 void test_isBlank() { | 73 void test_isBlank() { |
| 58 expect(isBlank(null), isTrue); | 74 expect(isBlank(null), isTrue); |
| 59 expect(isBlank(''), isTrue); | 75 expect(isBlank(''), isTrue); |
| 60 expect(isBlank(' '), isTrue); | 76 expect(isBlank(' '), isTrue); |
| 61 expect(isBlank('\t'), isTrue); | 77 expect(isBlank('\t'), isTrue); |
| 62 expect(isBlank(' '), isTrue); | 78 expect(isBlank(' '), isTrue); |
| 63 expect(isBlank('X'), isFalse); | 79 expect(isBlank('X'), isFalse); |
| 64 } | 80 } |
| 65 | 81 |
| 66 void test_isDigit() { | 82 void test_isDigit() { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 expect(repeat('abc', 3), 'abcabcabc'); | 187 expect(repeat('abc', 3), 'abcabcabc'); |
| 172 } | 188 } |
| 173 | 189 |
| 174 void test_substringAfterLast() { | 190 void test_substringAfterLast() { |
| 175 expect(substringAfterLast('', '/'), ''); | 191 expect(substringAfterLast('', '/'), ''); |
| 176 expect(substringAfterLast('abc', ''), ''); | 192 expect(substringAfterLast('abc', ''), ''); |
| 177 expect(substringAfterLast('abc', 'd'), 'abc'); | 193 expect(substringAfterLast('abc', 'd'), 'abc'); |
| 178 expect(substringAfterLast('abcbde', 'b'), 'de'); | 194 expect(substringAfterLast('abcbde', 'b'), 'de'); |
| 179 } | 195 } |
| 180 } | 196 } |
| OLD | NEW |