treewide: add and apply a bunch of lints
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:jadb/const_data/kanji_grades.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test("Assert 2136 kanji in jouyou set", () {
|
||||
test('Assert 2136 kanji in jouyou set', () {
|
||||
expect(JOUYOU_KANJI_BY_GRADES.values.flattenedToSet.length, 2136);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,26 +4,26 @@ import 'dart:io';
|
||||
import 'package:jadb/models/create_empty_db.dart';
|
||||
import 'package:jadb/search.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:sqlite3/open.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
Future<DatabaseExecutor> setup_inmemory_database() async {
|
||||
final libsqlitePath = Platform.environment['LIBSQLITE_PATH'];
|
||||
|
||||
if (libsqlitePath == null) {
|
||||
throw Exception("LIBSQLITE_PATH is not set");
|
||||
throw Exception('LIBSQLITE_PATH is not set');
|
||||
}
|
||||
|
||||
final db_connection = await createDatabaseFactoryFfi(
|
||||
final dbConnection = await createDatabaseFactoryFfi(
|
||||
ffiInit: () =>
|
||||
open.overrideForAll(() => DynamicLibrary.open(libsqlitePath)),
|
||||
).openDatabase(':memory:');
|
||||
|
||||
return db_connection;
|
||||
return dbConnection;
|
||||
}
|
||||
|
||||
void main() {
|
||||
test("Create empty db", () async {
|
||||
test('Create empty db', () async {
|
||||
final db = await setup_inmemory_database();
|
||||
|
||||
await createEmptyDb(db);
|
||||
|
||||
@@ -4,26 +4,26 @@ import 'package:test/test.dart';
|
||||
import 'setup_database_connection.dart';
|
||||
|
||||
void main() {
|
||||
test("Filter kanji", () async {
|
||||
test('Filter kanji', () async {
|
||||
final connection = await setup_database_connection();
|
||||
|
||||
final result = await connection.filterKanji([
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"漢",
|
||||
"字",
|
||||
"地",
|
||||
"字",
|
||||
"か",
|
||||
"な",
|
||||
".",
|
||||
"!",
|
||||
"@",
|
||||
";",
|
||||
"々",
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
'漢',
|
||||
'字',
|
||||
'地',
|
||||
'字',
|
||||
'か',
|
||||
'な',
|
||||
'.',
|
||||
'!',
|
||||
'@',
|
||||
';',
|
||||
'々',
|
||||
], deduplicate: false);
|
||||
|
||||
expect(result.join(), "漢字地字");
|
||||
expect(result.join(), '漢字地字');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@ import 'package:test/test.dart';
|
||||
import 'setup_database_connection.dart';
|
||||
|
||||
void main() {
|
||||
test("Search a kanji", () async {
|
||||
test('Search a kanji', () async {
|
||||
final connection = await setup_database_connection();
|
||||
|
||||
final result = await connection.jadbSearchKanji('漢');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
group("Search all jouyou kanji", () {
|
||||
group('Search all jouyou kanji', () {
|
||||
JOUYOU_KANJI_BY_GRADES.forEach((grade, characters) {
|
||||
test("Search all kanji in grade $grade", () async {
|
||||
test('Search all kanji in grade $grade', () async {
|
||||
final connection = await setup_database_connection();
|
||||
|
||||
for (final character in characters) {
|
||||
|
||||
@@ -4,21 +4,21 @@ import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
import 'package:sqflite_common/sqlite_api.dart';
|
||||
|
||||
Future<Database> setup_database_connection() async {
|
||||
final lib_sqlite_path = Platform.environment['LIBSQLITE_PATH'];
|
||||
final jadb_path = Platform.environment['JADB_PATH'];
|
||||
final libSqlitePath = Platform.environment['LIBSQLITE_PATH'];
|
||||
final jadbPath = Platform.environment['JADB_PATH'];
|
||||
|
||||
if (lib_sqlite_path == null) {
|
||||
throw Exception("LIBSQLITE_PATH is not set");
|
||||
if (libSqlitePath == null) {
|
||||
throw Exception('LIBSQLITE_PATH is not set');
|
||||
}
|
||||
|
||||
if (jadb_path == null) {
|
||||
throw Exception("JADB_PATH is not set");
|
||||
if (jadbPath == null) {
|
||||
throw Exception('JADB_PATH is not set');
|
||||
}
|
||||
|
||||
final db_connection = await openLocalDb(
|
||||
libsqlitePath: lib_sqlite_path,
|
||||
jadbPath: jadb_path,
|
||||
final dbConnection = await openLocalDb(
|
||||
libsqlitePath: libSqlitePath,
|
||||
jadbPath: jadbPath,
|
||||
);
|
||||
|
||||
return db_connection;
|
||||
return dbConnection;
|
||||
}
|
||||
|
||||
@@ -4,59 +4,59 @@ import 'package:test/test.dart';
|
||||
import 'setup_database_connection.dart';
|
||||
|
||||
void main() {
|
||||
test("Search a word - english - auto", () async {
|
||||
test('Search a word - english - auto', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbSearchWord("kana");
|
||||
final result = await connection.jadbSearchWord('kana');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test("Get word search count - english - auto", () async {
|
||||
test('Get word search count - english - auto', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbSearchWordCount("kana");
|
||||
final result = await connection.jadbSearchWordCount('kana');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test("Search a word - japanese kana - auto", () async {
|
||||
test('Search a word - japanese kana - auto', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbSearchWord("かな");
|
||||
final result = await connection.jadbSearchWord('かな');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test("Get word search count - japanese kana - auto", () async {
|
||||
test('Get word search count - japanese kana - auto', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbSearchWordCount("かな");
|
||||
final result = await connection.jadbSearchWordCount('かな');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test("Search a word - japanese kanji - auto", () async {
|
||||
test('Search a word - japanese kanji - auto', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbSearchWord("仮名");
|
||||
final result = await connection.jadbSearchWord('仮名');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test("Get word search count - japanese kanji - auto", () async {
|
||||
test('Get word search count - japanese kanji - auto', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbSearchWordCount("仮名");
|
||||
final result = await connection.jadbSearchWordCount('仮名');
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test("Get a word by id", () async {
|
||||
test('Get a word by id', () async {
|
||||
final connection = await setup_database_connection();
|
||||
final result = await connection.jadbGetWordById(1577090);
|
||||
expect(result, isNotNull);
|
||||
});
|
||||
|
||||
test(
|
||||
"Serialize all words",
|
||||
'Serialize all words',
|
||||
() async {
|
||||
final connection = await setup_database_connection();
|
||||
|
||||
// Test serializing all words
|
||||
for (final letter in "aiueoksthnmyrw".split("")) {
|
||||
for (final letter in 'aiueoksthnmyrw'.split('')) {
|
||||
await connection.jadbSearchWord(letter);
|
||||
}
|
||||
},
|
||||
timeout: Timeout.factor(100),
|
||||
skip: "Very slow test",
|
||||
skip: 'Very slow test',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,65 +2,65 @@ import 'package:jadb/util/romaji_transliteration.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group("Romaji -> Hiragana", () {
|
||||
test("Basic test", () {
|
||||
final result = transliterateLatinToHiragana("katamari");
|
||||
expect(result, "かたまり");
|
||||
group('Romaji -> Hiragana', () {
|
||||
test('Basic test', () {
|
||||
final result = transliterateLatinToHiragana('katamari');
|
||||
expect(result, 'かたまり');
|
||||
});
|
||||
|
||||
test("Basic test with diacritics", () {
|
||||
final result = transliterateLatinToHiragana("gadamari");
|
||||
expect(result, "がだまり");
|
||||
test('Basic test with diacritics', () {
|
||||
final result = transliterateLatinToHiragana('gadamari');
|
||||
expect(result, 'がだまり');
|
||||
});
|
||||
|
||||
test("wi and we", () {
|
||||
final result = transliterateLatinToHiragana("wiwe");
|
||||
expect(result, "うぃうぇ");
|
||||
test('wi and we', () {
|
||||
final result = transliterateLatinToHiragana('wiwe');
|
||||
expect(result, 'うぃうぇ');
|
||||
});
|
||||
|
||||
test("nb = mb", () {
|
||||
final result = transliterateLatinToHiragana("kanpai");
|
||||
expect(result, "かんぱい");
|
||||
test('nb = mb', () {
|
||||
final result = transliterateLatinToHiragana('kanpai');
|
||||
expect(result, 'かんぱい');
|
||||
|
||||
final result2 = transliterateLatinToHiragana("kampai");
|
||||
expect(result2, "かんぱい");
|
||||
final result2 = transliterateLatinToHiragana('kampai');
|
||||
expect(result2, 'かんぱい');
|
||||
});
|
||||
|
||||
test("Double n", () {
|
||||
final result = transliterateLatinToHiragana("konnichiha");
|
||||
expect(result, "こんにちは");
|
||||
test('Double n', () {
|
||||
final result = transliterateLatinToHiragana('konnichiha');
|
||||
expect(result, 'こんにちは');
|
||||
});
|
||||
|
||||
test("Double consonant", () {
|
||||
final result = transliterateLatinToHiragana("kappa");
|
||||
expect(result, "かっぱ");
|
||||
test('Double consonant', () {
|
||||
final result = transliterateLatinToHiragana('kappa');
|
||||
expect(result, 'かっぱ');
|
||||
});
|
||||
});
|
||||
|
||||
group("Hiragana -> Romaji", () {
|
||||
test("Basic test", () {
|
||||
final result = transliterateHiraganaToLatin("かたまり");
|
||||
expect(result, "katamari");
|
||||
group('Hiragana -> Romaji', () {
|
||||
test('Basic test', () {
|
||||
final result = transliterateHiraganaToLatin('かたまり');
|
||||
expect(result, 'katamari');
|
||||
});
|
||||
|
||||
test("Basic test with diacritics", () {
|
||||
final result = transliterateHiraganaToLatin("がだまり");
|
||||
expect(result, "gadamari");
|
||||
test('Basic test with diacritics', () {
|
||||
final result = transliterateHiraganaToLatin('がだまり');
|
||||
expect(result, 'gadamari');
|
||||
});
|
||||
|
||||
test("whi and whe", () {
|
||||
final result = transliterateHiraganaToLatin("うぃうぇ");
|
||||
expect(result, "whiwhe");
|
||||
test('whi and whe', () {
|
||||
final result = transliterateHiraganaToLatin('うぃうぇ');
|
||||
expect(result, 'whiwhe');
|
||||
});
|
||||
|
||||
test("Double n", () {
|
||||
final result = transliterateHiraganaToLatin("こんにちは");
|
||||
expect(result, "konnichiha");
|
||||
test('Double n', () {
|
||||
final result = transliterateHiraganaToLatin('こんにちは');
|
||||
expect(result, 'konnichiha');
|
||||
});
|
||||
|
||||
test("Double consonant", () {
|
||||
final result = transliterateHiraganaToLatin("かっぱ");
|
||||
expect(result, "kappa");
|
||||
test('Double consonant', () {
|
||||
final result = transliterateHiraganaToLatin('かっぱ');
|
||||
expect(result, 'kappa');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user