diff options
| author | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
|---|---|---|
| committer | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
| commit | 449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch) | |
| tree | c131c3528c4d517f56e19b854a7453fedb097d40 /test/model/naming_pattern_test.dart | |
| download | aves-src-master.tar.gz aves-src-master.zip | |
Diffstat (limited to 'test/model/naming_pattern_test.dart')
| -rw-r--r-- | test/model/naming_pattern_test.dart | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/model/naming_pattern_test.dart b/test/model/naming_pattern_test.dart new file mode 100644 index 0000000..b5d0daf --- /dev/null +++ b/test/model/naming_pattern_test.dart @@ -0,0 +1,56 @@ +import 'package:aves/model/naming_pattern.dart'; +import 'package:intl/date_symbol_data_local.dart'; +import 'package:test/test.dart'; + +void main() { + setUpAll(() async { + await initializeDateFormatting(); + }); + + test('mixed processors', () { + const entryCount = 42; + const locale = 'en'; + expect( + NamingPattern.from( + userPattern: 'pure literal', + entryCount: entryCount, + locale: locale, + ).processors, + [ + const LiteralNamingProcessor('pure literal'), + ], + ); + expect( + NamingPattern.from( + userPattern: 'prefix<date,yyyy-MM-ddTHH:mm:ss>suffix', + entryCount: entryCount, + locale: locale, + ).processors, + [ + const LiteralNamingProcessor('prefix'), + DateNamingProcessor('yyyy-MM-ddTHH:mm:ss', locale), + const LiteralNamingProcessor('suffix'), + ], + ); + expect( + NamingPattern.from( + userPattern: '<date,yyyy-MM-ddTHH:mm:ss> <name>', + entryCount: entryCount, + locale: locale, + ).processors, + [ + DateNamingProcessor('yyyy-MM-ddTHH:mm:ss', locale), + const LiteralNamingProcessor(' '), + const NameNamingProcessor(), + ], + ); + }); + + test('insertion offset', () { + const userPattern = '<date,yyyy-MM-ddTHH:mm:ss> infix <name>'; + expect(NamingPattern.getInsertionOffset(userPattern, -1), 0); + expect(NamingPattern.getInsertionOffset(userPattern, 1234), userPattern.length); + expect(NamingPattern.getInsertionOffset(userPattern, 4), 26); + expect(NamingPattern.getInsertionOffset(userPattern, 30), 30); + }); +} |
