const_data/radicals: store both formal and informal variant of radical
Build and test / build (push) Successful in 5m47s
Build and test / build (push) Successful in 5m47s
This commit is contained in:
@@ -7,32 +7,29 @@ import 'package:test/test.dart';
|
||||
import 'setup_database_connection.dart';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'All constant radicals should exist in the database',
|
||||
() async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final allRadicalsInDb = await connection.query(
|
||||
RADKFILETableNames.radkfile,
|
||||
columns: ['radical'],
|
||||
distinct: true,
|
||||
);
|
||||
test('All constant radicals should exist in the database', () async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final allRadicalsInDb = await connection.query(
|
||||
RADKFILETableNames.radkfile,
|
||||
columns: ['radical'],
|
||||
distinct: true,
|
||||
);
|
||||
|
||||
final radicalsInDb = allRadicalsInDb
|
||||
.map((e) => e['radical'] as String)
|
||||
.toSet();
|
||||
final radicalsInDb = allRadicalsInDb
|
||||
.map((e) => e['radical'] as String)
|
||||
.toSet();
|
||||
|
||||
final missingRadicals = radicals.values.flattenedToSet.difference(
|
||||
radicalsInDb,
|
||||
);
|
||||
final missingRadicals = radicals.values.flattenedToSet
|
||||
.map((e) => e.formalVariant)
|
||||
.toSet()
|
||||
.difference(radicalsInDb);
|
||||
|
||||
expect(
|
||||
missingRadicals,
|
||||
isEmpty,
|
||||
reason: 'Missing radicals in database: $missingRadicals',
|
||||
);
|
||||
},
|
||||
skip: 'Test is valid, code is broken, fix me',
|
||||
);
|
||||
expect(
|
||||
missingRadicals,
|
||||
isEmpty,
|
||||
reason: 'Missing radicals in database: $missingRadicals',
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'All radicals in database should be in the constant radical list',
|
||||
@@ -49,7 +46,7 @@ void main() {
|
||||
.toSet();
|
||||
|
||||
final extraRadicals = radicalsInDb.difference(
|
||||
radicals.values.flattenedToSet,
|
||||
radicals.values.flattenedToSet.map((e) => e.formalVariant).toSet(),
|
||||
);
|
||||
|
||||
expect(
|
||||
@@ -59,21 +56,35 @@ void main() {
|
||||
'Extra radicals in database missing in the constant list: $extraRadicals',
|
||||
);
|
||||
},
|
||||
skip: 'Test is valid, code is broken, fix me',
|
||||
);
|
||||
|
||||
group(
|
||||
'All radicals should return results',
|
||||
test(
|
||||
'All constant radicals are located in the correct stroke count group',
|
||||
() {
|
||||
for (final radical in radicals.values.flattened) {
|
||||
test(' - $radical', () async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final result = await connection.jadbSearchKanjiByRadicals([radical]);
|
||||
expect(result, isNotEmpty);
|
||||
});
|
||||
for (final mapEntry in radicals.entries) {
|
||||
final strokeCount = mapEntry.key;
|
||||
final radicalsInGroup = mapEntry.value;
|
||||
for (final radical in radicalsInGroup) {
|
||||
expect(
|
||||
strokeCount,
|
||||
radical.strokeCount,
|
||||
reason:
|
||||
'Radical ${radical.formalVariant} should have stroke count $strokeCount but has ${radical.strokeCount}',
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
skip:
|
||||
'These will be automatically fixed once the other radical tests are passing',
|
||||
);
|
||||
|
||||
group('All radicals should return results', () {
|
||||
for (final radical in radicals.values.flattened) {
|
||||
test(' - $radical', () async {
|
||||
final connection = await setupDatabaseConnection();
|
||||
final result = await connection.jadbSearchKanjiByRadicals([
|
||||
radical.formalVariant,
|
||||
]);
|
||||
expect(result, isNotEmpty);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user