39 lines
1.0 KiB
Dart
39 lines
1.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:kanimaji/kanjivg_parser.dart';
|
|
|
|
void main() {
|
|
final kanjivgDir = Directory(String.fromEnvironment('KANJIVG_PATH'));
|
|
final kanjivgFiles = kanjivgDir
|
|
.listSync(recursive: true)
|
|
.whereType<File>()
|
|
.where((f) => f.path.endsWith('.svg'))
|
|
.toList();
|
|
|
|
for (final file in kanjivgFiles) {
|
|
test('Test parsing KanjiVG file ', () async {
|
|
final content = await file.readAsString();
|
|
try {
|
|
final tree = KanjiVGItem.parseFromXml(content);
|
|
|
|
expect(tree, isNotNull, reason: 'Failed to parse ${file.path}');
|
|
|
|
expect(
|
|
tree.strokeNumbers,
|
|
isNotEmpty,
|
|
reason: 'No stroke numbers found in ${file.path}',
|
|
);
|
|
|
|
expect(
|
|
tree.strokeNumbers.length,
|
|
tree.paths.length,
|
|
reason: 'Mismatch between stroke numbers and paths in ${file.path}',
|
|
);
|
|
} catch (e) {
|
|
fail('Error parsing ${file.path}: $e');
|
|
}
|
|
});
|
|
}
|
|
}
|