|
| 1 | +// Copyright (c) 2025, 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 | +// Conventions for tests written using `package:test_reflective_loader` aren't |
| 6 | +// compatible with the `non_constant_identifier_names` lint. |
| 7 | +// ignore_for_file: non_constant_identifier_names |
| 8 | + |
| 9 | +import 'package:analyzer_utilities/extensions/string.dart'; |
| 10 | +import 'package:test/test.dart'; |
| 11 | +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 12 | + |
| 13 | +void main() { |
| 14 | + defineReflectiveSuite(() { |
| 15 | + defineReflectiveTests(StringExtensionTest); |
| 16 | + }); |
| 17 | +} |
| 18 | + |
| 19 | +@reflectiveTest |
| 20 | +class StringExtensionTest { |
| 21 | + void test_toCamelCase() { |
| 22 | + expect('CAMEL_CASE'.toCamelCase(), 'camelCase'); |
| 23 | + expect('alreadyCamel_case'.toCamelCase(), 'alreadycamelCase'); |
| 24 | + expect('FOO_123_BAR'.toCamelCase(), 'foo123Bar'); |
| 25 | + expect('FOO'.toCamelCase(), 'foo'); |
| 26 | + expect('___'.toCamelCase(), '___'); |
| 27 | + expect(''.toCamelCase(), ''); |
| 28 | + expect('_FOO_BAR'.toCamelCase(), '_fooBar'); |
| 29 | + expect('FOO__BAR'.toCamelCase(), 'fooBar'); |
| 30 | + expect('FOO_BAR_'.toCamelCase(), 'fooBar'); |
| 31 | + } |
| 32 | + |
| 33 | + void test_toPascalCase() { |
| 34 | + expect('PASCAL_CASE'.toPascalCase(), 'PascalCase'); |
| 35 | + expect('AlreadyPascal_case'.toPascalCase(), 'AlreadypascalCase'); |
| 36 | + expect('FOO_123_BAR'.toPascalCase(), 'Foo123Bar'); |
| 37 | + expect('FOO'.toPascalCase(), 'Foo'); |
| 38 | + expect('___'.toPascalCase(), '___'); |
| 39 | + expect(''.toPascalCase(), ''); |
| 40 | + expect('_FOO_BAR'.toPascalCase(), '_FooBar'); |
| 41 | + expect('FOO__BAR'.toPascalCase(), 'FooBar'); |
| 42 | + expect('FOO_BAR_'.toPascalCase(), 'FooBar'); |
| 43 | + } |
| 44 | +} |
0 commit comments