halkyon/halkyon_learn_flutter/test/feature/kanji/model/radical_test.dart

37 lines
1.1 KiB
Dart
Raw Normal View History

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_learn_flutter/src/feature/kanji/model/radical.dart';
void main() {
test('the 214 Kangxi radicals in their order, by their strokes from 1 '
'to 17', () {
expect(
[for (final radical in radicals) radical.number],
[
for (var number = 1; number <= 214; number++) number,
],
);
final strokes = [for (final radical in radicals) radical.strokes];
expect(strokes, orderedEquals([...strokes]..sort()));
expect((strokes.first, strokes.last), (1, 17));
// Const, as the table is: a record compares its lists by identity.
expect(radicals[84], const (
number: 85,
character: '水',
variants: ['氵'],
strokes: 4,
name: 'water',
));
});
test('each is one character, as is every form it takes in kanji', () {
for (final radical in radicals) {
for (final form in [radical.character, ...radical.variants]) {
expect(form.runes, hasLength(1), reason: '${radical.number}');
}
}
});
test("a radical's label is the dictionary's", () {
expect(radicalLabel(85), 'radical:85');
});
}