import 'dart:io'; import 'package:halkyon_learn_curator/src/sources/kanjivg.dart'; import 'package:test/test.dart'; void main() { late Map strokes; setUpAll(() async { strokes = kanjivgStrokes( await File('test/fixtures/kanjivg-sample.xml').readAsString(), ); }); test("a character's strokes are its paths in the order they're written", () { final eat = strokes['食']!; expect(eat.strokes, hasLength(9)); expect(eat.strokes.first, startsWith('M52.75,10.5c')); expect(eat.strokes.last, startsWith('M51.5,71C')); expect(strokes['あ']!.strokes, hasLength(3)); }); test('its components are the characters KanjiVG first splits it into, ' 'looking through groups that are none', () { expect(strokes['語']!.components, ['言', '吾']); expect(strokes['食']!.components, isEmpty); }); test("the character is the code point in the entry's id, not KanjiVG's " 'element name, which can be wrong', () { // KanjiVG's U+6A45 (橅) names itself 機. expect(strokes.keys, containsAll(['橅', 'あ', '食', '語'])); expect(strokes.keys, isNot(contains('機'))); }); test('the stroke files hold every 256 code points, named by their upper ' 'bits', () { expect(strokeFileOf('食'), '098'); expect(strokeFileOf('あ'), '030'); expect(strokeFileOf('𠀋'), '200'); final files = strokeFiles(strokes); expect(files.keys, containsAll(['030', '098', '08a', '06a'])); expect(files['08a']!['語'], { 's': strokes['語']!.strokes, 'c': ['言', '吾'], }); expect(files['098']!['食'], {'s': strokes['食']!.strokes}); }); }