| 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; |  | 
|    6  |  | 
|    7 import 'package:analysis_server/src/services/correction/strings.dart'; |    5 import 'package:analysis_server/src/services/correction/strings.dart'; | 
|    8 import 'package:test/test.dart' hide isEmpty; |    6 import 'package:test/test.dart' hide isEmpty; | 
|    9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |    7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 
|   10  |    8  | 
|   11 main() { |    9 main() { | 
|   12   defineReflectiveSuite(() { |   10   defineReflectiveSuite(() { | 
|   13     defineReflectiveTests(StringsTest); |   11     defineReflectiveTests(StringsTest); | 
|   14   }); |   12   }); | 
|   15 } |   13 } | 
|   16  |   14  | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   68     expect(findCommonPrefix('1234abcdef', '1234xyz'), 4); |   66     expect(findCommonPrefix('1234abcdef', '1234xyz'), 4); | 
|   69     expect(findCommonPrefix('123', '123xyz'), 3); |   67     expect(findCommonPrefix('123', '123xyz'), 3); | 
|   70   } |   68   } | 
|   71  |   69  | 
|   72   void test_findCommonSuffix() { |   70   void test_findCommonSuffix() { | 
|   73     expect(findCommonSuffix('abc', 'xyz'), 0); |   71     expect(findCommonSuffix('abc', 'xyz'), 0); | 
|   74     expect(findCommonSuffix('abcdef1234', 'xyz1234'), 4); |   72     expect(findCommonSuffix('abcdef1234', 'xyz1234'), 4); | 
|   75     expect(findCommonSuffix('123', 'xyz123'), 3); |   73     expect(findCommonSuffix('123', 'xyz123'), 3); | 
|   76   } |   74   } | 
|   77  |   75  | 
|   78   void test_getCamelWords() { |  | 
|   79     expect(getCamelWords(null), []); |  | 
|   80     expect(getCamelWords(''), []); |  | 
|   81     expect(getCamelWords('getCamelWords'), ['get', 'Camel', 'Words']); |  | 
|   82     expect(getCamelWords('getHTMLText'), ['get', 'HTML', 'Text']); |  | 
|   83   } |  | 
|   84  |  | 
|   85   void test_isBlank() { |   76   void test_isBlank() { | 
|   86     expect(isBlank(null), isTrue); |   77     expect(isBlank(null), isTrue); | 
|   87     expect(isBlank(''), isTrue); |   78     expect(isBlank(''), isTrue); | 
|   88     expect(isBlank(' '), isTrue); |   79     expect(isBlank(' '), isTrue); | 
|   89     expect(isBlank('\t'), isTrue); |   80     expect(isBlank('\t'), isTrue); | 
|   90     expect(isBlank('  '), isTrue); |   81     expect(isBlank('  '), isTrue); | 
|   91     expect(isBlank('X'), isFalse); |   82     expect(isBlank('X'), isFalse); | 
|   92   } |   83   } | 
|   93  |   84  | 
|   94   void test_isDigit() { |   85   void test_isDigit() { | 
|   95     for (int c in '0123456789'.codeUnits) { |   86     for (int c in '0123456789'.codeUnits) { | 
|   96       expect(isDigit(c), isTrue); |   87       expect(isDigit(c), isTrue); | 
|   97     } |   88     } | 
|   98     expect(isDigit(' '.codeUnitAt(0)), isFalse); |   89     expect(isDigit(' '.codeUnitAt(0)), isFalse); | 
|   99     expect(isDigit('A'.codeUnitAt(0)), isFalse); |   90     expect(isDigit('A'.codeUnitAt(0)), isFalse); | 
|  100   } |   91   } | 
|  101  |   92  | 
|  102   void test_isEmpty() { |  | 
|  103     expect(isEmpty(null), isTrue); |  | 
|  104     expect(isEmpty(''), isTrue); |  | 
|  105     expect(isEmpty('X'), isFalse); |  | 
|  106     expect(isEmpty(' '), isFalse); |  | 
|  107   } |  | 
|  108  |  | 
|  109   void test_isLetter() { |   93   void test_isLetter() { | 
|  110     for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { |   94     for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { | 
|  111       expect(isLetter(c), isTrue); |   95       expect(isLetter(c), isTrue); | 
|  112     } |   96     } | 
|  113     for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { |   97     for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { | 
|  114       expect(isLetter(c), isTrue); |   98       expect(isLetter(c), isTrue); | 
|  115     } |   99     } | 
|  116     expect(isLetter(' '.codeUnitAt(0)), isFalse); |  100     expect(isLetter(' '.codeUnitAt(0)), isFalse); | 
|  117     expect(isLetter('0'.codeUnitAt(0)), isFalse); |  101     expect(isLetter('0'.codeUnitAt(0)), isFalse); | 
|  118   } |  102   } | 
|  119  |  103  | 
|  120   void test_isLetterOrDigit() { |  104   void test_isLetterOrDigit() { | 
|  121     for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { |  105     for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { | 
|  122       expect(isLetterOrDigit(c), isTrue); |  106       expect(isLetterOrDigit(c), isTrue); | 
|  123     } |  107     } | 
|  124     for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { |  108     for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { | 
|  125       expect(isLetterOrDigit(c), isTrue); |  109       expect(isLetterOrDigit(c), isTrue); | 
|  126     } |  110     } | 
|  127     for (int c in '0123456789'.codeUnits) { |  111     for (int c in '0123456789'.codeUnits) { | 
|  128       expect(isLetterOrDigit(c), isTrue); |  112       expect(isLetterOrDigit(c), isTrue); | 
|  129     } |  113     } | 
|  130     expect(isLetterOrDigit(' '.codeUnitAt(0)), isFalse); |  114     expect(isLetterOrDigit(' '.codeUnitAt(0)), isFalse); | 
|  131     expect(isLetterOrDigit('.'.codeUnitAt(0)), isFalse); |  115     expect(isLetterOrDigit('.'.codeUnitAt(0)), isFalse); | 
|  132   } |  116   } | 
|  133  |  117  | 
|  134   void test_isLowerCase() { |  | 
|  135     for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { |  | 
|  136       expect(isLowerCase(c), isTrue); |  | 
|  137     } |  | 
|  138     for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { |  | 
|  139       expect(isLowerCase(c), isFalse); |  | 
|  140     } |  | 
|  141     expect(isLowerCase(' '.codeUnitAt(0)), isFalse); |  | 
|  142     expect(isLowerCase('0'.codeUnitAt(0)), isFalse); |  | 
|  143   } |  | 
|  144  |  | 
|  145   void test_isSpace() { |  118   void test_isSpace() { | 
|  146     expect(isSpace(' '.codeUnitAt(0)), isTrue); |  119     expect(isSpace(' '.codeUnitAt(0)), isTrue); | 
|  147     expect(isSpace('\t'.codeUnitAt(0)), isTrue); |  120     expect(isSpace('\t'.codeUnitAt(0)), isTrue); | 
|  148     expect(isSpace('\r'.codeUnitAt(0)), isFalse); |  121     expect(isSpace('\r'.codeUnitAt(0)), isFalse); | 
|  149     expect(isSpace('\n'.codeUnitAt(0)), isFalse); |  122     expect(isSpace('\n'.codeUnitAt(0)), isFalse); | 
|  150     expect(isSpace('0'.codeUnitAt(0)), isFalse); |  123     expect(isSpace('0'.codeUnitAt(0)), isFalse); | 
|  151     expect(isSpace('A'.codeUnitAt(0)), isFalse); |  124     expect(isSpace('A'.codeUnitAt(0)), isFalse); | 
|  152   } |  125   } | 
|  153  |  126  | 
|  154   void test_isUpperCase() { |  | 
|  155     for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { |  | 
|  156       expect(isUpperCase(c), isFalse); |  | 
|  157     } |  | 
|  158     for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { |  | 
|  159       expect(isUpperCase(c), isTrue); |  | 
|  160     } |  | 
|  161     expect(isUpperCase(' '.codeUnitAt(0)), isFalse); |  | 
|  162     expect(isUpperCase('0'.codeUnitAt(0)), isFalse); |  | 
|  163   } |  | 
|  164  |  | 
|  165   void test_isWhitespace() { |  127   void test_isWhitespace() { | 
|  166     expect(isWhitespace(' '.codeUnitAt(0)), isTrue); |  128     expect(isWhitespace(' '.codeUnitAt(0)), isTrue); | 
|  167     expect(isWhitespace('\t'.codeUnitAt(0)), isTrue); |  129     expect(isWhitespace('\t'.codeUnitAt(0)), isTrue); | 
|  168     expect(isWhitespace('\r'.codeUnitAt(0)), isTrue); |  130     expect(isWhitespace('\r'.codeUnitAt(0)), isTrue); | 
|  169     expect(isWhitespace('\n'.codeUnitAt(0)), isTrue); |  131     expect(isWhitespace('\n'.codeUnitAt(0)), isTrue); | 
|  170     expect(isWhitespace('0'.codeUnitAt(0)), isFalse); |  132     expect(isWhitespace('0'.codeUnitAt(0)), isFalse); | 
|  171     expect(isWhitespace('A'.codeUnitAt(0)), isFalse); |  133     expect(isWhitespace('A'.codeUnitAt(0)), isFalse); | 
|  172   } |  134   } | 
|  173  |  135  | 
|  174   void test_remove() { |  136   void test_remove() { | 
|  175     expect(remove(null, 'x'), null); |  137     expect(remove(null, 'x'), null); | 
|  176     expect(remove('abc', null), 'abc'); |  138     expect(remove('abc', null), 'abc'); | 
|  177     expect(remove('abc abbc abbbc', 'b'), 'ac ac ac'); |  139     expect(remove('abc abbc abbbc', 'b'), 'ac ac ac'); | 
|  178     expect(remove('abc abbc abbbc', 'bc'), 'a ab abb'); |  140     expect(remove('abc abbc abbbc', 'bc'), 'a ab abb'); | 
|  179   } |  141   } | 
|  180  |  142  | 
|  181   void test_removeEnd() { |  143   void test_removeEnd() { | 
|  182     expect(removeEnd(null, 'x'), null); |  144     expect(removeEnd(null, 'x'), null); | 
|  183     expect(removeEnd('abc', null), 'abc'); |  145     expect(removeEnd('abc', null), 'abc'); | 
|  184     expect(removeEnd('www.domain.com', '.com.'), 'www.domain.com'); |  146     expect(removeEnd('www.domain.com', '.com.'), 'www.domain.com'); | 
|  185     expect(removeEnd('www.domain.com', 'domain'), 'www.domain.com'); |  147     expect(removeEnd('www.domain.com', 'domain'), 'www.domain.com'); | 
|  186     expect(removeEnd('www.domain.com', '.com'), 'www.domain'); |  148     expect(removeEnd('www.domain.com', '.com'), 'www.domain'); | 
|  187   } |  149   } | 
|  188  |  150  | 
|  189   void test_removeStart() { |  | 
|  190     expect(removeStart(null, 'x'), null); |  | 
|  191     expect(removeStart('abc', null), 'abc'); |  | 
|  192     expect(removeStart('abcTest', 'abc'), 'Test'); |  | 
|  193     expect(removeStart('my abcTest', 'abc'), 'my abcTest'); |  | 
|  194   } |  | 
|  195  |  | 
|  196   void test_repeat() { |  151   void test_repeat() { | 
|  197     expect(repeat('x', 0), ''); |  152     expect(repeat('x', 0), ''); | 
|  198     expect(repeat('x', 5), 'xxxxx'); |  153     expect(repeat('x', 5), 'xxxxx'); | 
|  199     expect(repeat('abc', 3), 'abcabcabc'); |  154     expect(repeat('abc', 3), 'abcabcabc'); | 
|  200   } |  155   } | 
|  201  |  156  | 
|  202   void test_substringAfterLast() { |  157   void test_substringAfterLast() { | 
|  203     expect(substringAfterLast('', '/'), ''); |  158     expect(substringAfterLast('', '/'), ''); | 
|  204     expect(substringAfterLast('abc', ''), ''); |  159     expect(substringAfterLast('abc', ''), ''); | 
|  205     expect(substringAfterLast('abc', 'd'), 'abc'); |  160     expect(substringAfterLast('abc', 'd'), 'abc'); | 
|  206     expect(substringAfterLast('abcbde', 'b'), 'de'); |  161     expect(substringAfterLast('abcbde', 'b'), 'de'); | 
|  207   } |  162   } | 
|  208 } |  163 } | 
| OLD | NEW |