aboutsummaryrefslogtreecommitdiff
path: root/test/test-japanese.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-28 10:47:02 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-28 10:47:02 -0400
commit0d80fcdf86745da133e4510eeea809a4eeafe120 (patch)
tree07c55c136223a8a1c913a0d2380ba3d1ee3c6665 /test/test-japanese.js
parentcbc7e2646d2ce34f1aff7ca2b737fdb2db690c40 (diff)
Move Japanese utility functions out of display-generator.js
Diffstat (limited to 'test/test-japanese.js')
-rw-r--r--test/test-japanese.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/test-japanese.js b/test/test-japanese.js
index c5d220e7..eab632bf 100644
--- a/test/test-japanese.js
+++ b/test/test-japanese.js
@@ -392,6 +392,59 @@ function testDistributeFuriganaInflected() {
}
}
+function testIsMoraPitchHigh() {
+ const data = [
+ [[0, 0], false],
+ [[1, 0], true],
+ [[2, 0], true],
+ [[3, 0], true],
+
+ [[0, 1], true],
+ [[1, 1], false],
+ [[2, 1], false],
+ [[3, 1], false],
+
+ [[0, 2], true],
+ [[1, 2], true],
+ [[2, 2], false],
+ [[3, 2], false],
+
+ [[0, 3], true],
+ [[1, 3], true],
+ [[2, 3], true],
+ [[3, 3], false],
+
+ [[0, 4], true],
+ [[1, 4], true],
+ [[2, 4], true],
+ [[3, 4], true]
+ ];
+
+ for (const [[moraIndex, pitchAccentPosition], expected] of data) {
+ const actual = jp.isMoraPitchHigh(moraIndex, pitchAccentPosition);
+ assert.strictEqual(actual, expected);
+ }
+}
+
+function testGetKanaMorae() {
+ const data = [
+ ['かこ', ['か', 'こ']],
+ ['かっこ', ['か', 'っ', 'こ']],
+ ['カコ', ['カ', 'コ']],
+ ['カッコ', ['カ', 'ッ', 'コ']],
+ ['コート', ['コ', 'ー', 'ト']],
+ ['ちゃんと', ['ちゃ', 'ん', 'と']],
+ ['とうきょう', ['と', 'う', 'きょ', 'う']],
+ ['ぎゅう', ['ぎゅ', 'う']],
+ ['ディスコ', ['ディ', 'ス', 'コ']]
+ ];
+
+ for (const [text, expected] of data) {
+ const actual = jp.getKanaMorae(text);
+ vm.assert.deepStrictEqual(actual, expected);
+ }
+}
+
function main() {
testIsCodePointKanji();
@@ -408,6 +461,8 @@ function main() {
testConvertAlphabeticToKana();
testDistributeFurigana();
testDistributeFuriganaInflected();
+ testIsMoraPitchHigh();
+ testGetKanaMorae();
}