diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-06 16:22:26 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-06 16:22:26 +0200 |
commit | cb78013884e3aa3b1e1a91722f5eeb78c62f6796 (patch) | |
tree | 72a40258a246607ecb59eb596e417f81181b59a7 /test/single | |
parent | 4e32a1942ff2478b557af1b900b3f3282d7ce55b (diff) |
update tests
Diffstat (limited to 'test/single')
-rw-r--r-- | test/single/api-japanese.test.ts | 29 | ||||
-rw-r--r-- | test/single/halfwidth2fullwidth.test.ts | 18 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/single/api-japanese.test.ts b/test/single/api-japanese.test.ts new file mode 100644 index 0000000..4e89c64 --- /dev/null +++ b/test/single/api-japanese.test.ts @@ -0,0 +1,29 @@ +import { assertEquals } from "../base.ts"; + +import Japanese from "../../api/japanese.ts"; + +interface Test { + input: [string, string]; + output: string; +}; + +const cases = [ + { input: ["繰り返す", "くりかえす"], output: "[繰](く)り[返](かえ)す" }, + { input: ["漢字テスト", "かんじてすと"], output: "[漢字](かんじ)テスト" }, + { input: ["凛々しく", "りりしく"], output: "[凛々](りり)しく" }, + { input: ["字のテスト", "じのテスト"], output: "[字](じ)のテスト" }, + { input: ["文字", "っ"], output: "[文字](っ)" }, + { input: ["文字りす", "りりりす"], output: "[文字](りり)りす" }, + { input: ["気を引き締める", "きをひきしめる"], output: "[気](き)を[引](ひ)き[締](し)める" }, +// https://japanese.stackexchange.com/questions/69521/reading-per-kanji-irregular-readings + { input: ["大口魚", "たら"], output: "[大口魚](たら)" }, +] satisfies Test[]; + +cases.forEach(({ input, output }) => { + Deno.test(`Japanese API class - ${input}`, async () => { + var jp = new Japanese(...input); + assertEquals(jp.furigana("refold-tools"), output); + }); +}); + + diff --git a/test/single/halfwidth2fullwidth.test.ts b/test/single/halfwidth2fullwidth.test.ts new file mode 100644 index 0000000..ec530e7 --- /dev/null +++ b/test/single/halfwidth2fullwidth.test.ts @@ -0,0 +1,18 @@ +import { assertEquals } from "../base.ts"; + +import "../../util/japanese.ts"; + +Deno.test("Japanese utils - Katakana widening", async () => { + const input = "これが オレのウィンターバケーション スタイル!"; + const output = "これが オレのウィンターバケーション スタイル!"; + + assertEquals(input.widenKatakana(), output); +}); + +Deno.test("Japanese utils - Kana normalize", async () => { + const input = "これが オレのウィンターバケーション スタイル!"; + const output = "これが おれのうぃんたーばけーしょん すたいる!"; + + assertEquals(input.normalizeKana(), output); +}); + |