WIP
This commit is contained in:
43
test/kanjivg_parser_test.dart
Normal file
43
test/kanjivg_parser_test.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:io';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kanimaji/kanjivg_parser.dart';
|
||||
|
||||
void main() {
|
||||
final kanjivgDirStr = Platform.environment['KANJIVG_PATH'];
|
||||
if (kanjivgDirStr == null) {
|
||||
throw Exception('KANJIVG_PATH environment variable not set');
|
||||
}
|
||||
final kanjivgDir = Directory(kanjivgDirStr);
|
||||
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 ${path.basename(file.path)}', () async {
|
||||
final content = await file.readAsString();
|
||||
try {
|
||||
final item = KanjiVGItem.parseFromXml(content);
|
||||
|
||||
expect(item, isNotNull, reason: 'Failed to parse ${file.path}');
|
||||
|
||||
expect(
|
||||
item.strokeNumbers,
|
||||
isNotEmpty,
|
||||
reason: 'No stroke numbers found in ${file.path}',
|
||||
);
|
||||
|
||||
expect(
|
||||
item.strokeNumbers.length,
|
||||
item.paths.length,
|
||||
reason: 'Mismatch between stroke numbers and paths in ${file.path}',
|
||||
);
|
||||
} catch (e) {
|
||||
fail('Error parsing ${file.path}: $e');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kanimaji/svg/parser.dart';
|
||||
import 'package:kanimaji/svg_parser.dart';
|
||||
|
||||
void main() {
|
||||
test('Test generating SVG path strings', () {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kanimaji/point.dart';
|
||||
import 'package:kanimaji/svg/parser.dart';
|
||||
import 'package:kanimaji/svg/path.dart';
|
||||
import 'package:kanimaji/primitives/path.dart';
|
||||
import 'package:kanimaji/primitives/point.dart';
|
||||
import 'package:kanimaji/svg_parser.dart';
|
||||
|
||||
void main() {
|
||||
group("Examples from the SVG spec", () {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import 'dart:math' show sqrt, pi;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kanimaji/point.dart';
|
||||
import 'package:kanimaji/svg/path.dart';
|
||||
import 'package:kanimaji/primitives/point.dart';
|
||||
import 'package:kanimaji/primitives/path.dart';
|
||||
|
||||
// from ..path import CubicBezier, QuadraticBezier, Line, Arc, Move, Close, Path
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// from svg.path import parser
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:kanimaji/point.dart';
|
||||
import 'package:kanimaji/svg/parser.dart'
|
||||
import 'package:kanimaji/primitives/point.dart';
|
||||
import 'package:kanimaji/svg_parser.dart'
|
||||
show Command, Token, commandifyPath, parsePath, tokenizePath;
|
||||
|
||||
class TokenizerTest {
|
||||
|
||||
Reference in New Issue
Block a user