OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'package:analyzer_plugin/src/utilities/string_utilities.dart'; |
| 6 import 'package:test/test.dart' hide isEmpty; |
| 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 8 |
| 9 main() { |
| 10 defineReflectiveSuite(() { |
| 11 defineReflectiveTests(StringUtilitiesTest); |
| 12 }); |
| 13 } |
| 14 |
| 15 @reflectiveTest |
| 16 class StringUtilitiesTest { |
| 17 void test_getCamelWords() { |
| 18 expect(getCamelWords(null), []); |
| 19 expect(getCamelWords(''), []); |
| 20 expect(getCamelWords('getCamelWords'), ['get', 'Camel', 'Words']); |
| 21 expect(getCamelWords('getHTMLText'), ['get', 'HTML', 'Text']); |
| 22 } |
| 23 |
| 24 void test_isEmpty() { |
| 25 expect(isEmpty(null), isTrue); |
| 26 expect(isEmpty(''), isTrue); |
| 27 expect(isEmpty('X'), isFalse); |
| 28 expect(isEmpty(' '), isFalse); |
| 29 } |
| 30 |
| 31 void test_isLowerCase() { |
| 32 for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { |
| 33 expect(isLowerCase(c), isTrue); |
| 34 } |
| 35 for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { |
| 36 expect(isLowerCase(c), isFalse); |
| 37 } |
| 38 expect(isLowerCase(' '.codeUnitAt(0)), isFalse); |
| 39 expect(isLowerCase('0'.codeUnitAt(0)), isFalse); |
| 40 } |
| 41 |
| 42 void test_isUpperCase() { |
| 43 for (int c in 'abcdefghijklmnopqrstuvwxyz'.codeUnits) { |
| 44 expect(isUpperCase(c), isFalse); |
| 45 } |
| 46 for (int c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.codeUnits) { |
| 47 expect(isUpperCase(c), isTrue); |
| 48 } |
| 49 expect(isUpperCase(' '.codeUnitAt(0)), isFalse); |
| 50 expect(isUpperCase('0'.codeUnitAt(0)), isFalse); |
| 51 } |
| 52 |
| 53 void test_removeStart() { |
| 54 expect(removeStart(null, 'x'), null); |
| 55 expect(removeStart('abc', null), 'abc'); |
| 56 expect(removeStart('abcTest', 'abc'), 'Test'); |
| 57 expect(removeStart('my abcTest', 'abc'), 'my abcTest'); |
| 58 } |
| 59 } |
OLD | NEW |