From 8c527b6eda2a3fafa1fbd7291ff527875bb07819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=20=E8=80=98?= Date: Sun, 12 Nov 2023 15:31:29 +0800 Subject: [PATCH] test: Intl.Segement --- test/test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test.ts b/test/test.ts index 32352cc..cc43d45 100644 --- a/test/test.ts +++ b/test/test.ts @@ -136,6 +136,7 @@ const cases: any[] = [ // 英文 [ "a", { STYLE_NORMAL: [["a"]], + STYLE_PASSPORT: [["a"]], STYLE_TONE: [["a"]], STYLE_TONE2: [["a"]], STYLE_TO3NE: [["a"]], @@ -144,6 +145,7 @@ const cases: any[] = [ } ], [ "aa", { STYLE_NORMAL: [["aa"]], + STYLE_PASSPORT: [["aa"]], STYLE_TONE: [["aa"]], STYLE_TONE2: [["aa"]], STYLE_TO3NE: [["aa"]], @@ -152,6 +154,7 @@ const cases: any[] = [ } ], [ "a a", { STYLE_NORMAL: [["a a"]], + STYLE_PASSPORT: [["a a"]], STYLE_TONE: [["a a"]], STYLE_TONE2: [["a a"]], STYLE_TO3NE: [["a a"]], @@ -160,6 +163,7 @@ const cases: any[] = [ } ], [ "一 一", { STYLE_NORMAL: [["yi"], [" "], ["yi"]], + STYLE_PASSPORT: [["YI"], [" "], ["YI"]], STYLE_TONE: [["yī"], [" "], ["yī"]], STYLE_TONE2: [["yi1"], [" "], ["yi1"]], STYLE_TO3NE: [["yi1"], [" "], ["yi1"]], @@ -170,6 +174,7 @@ const cases: any[] = [ // 中英混合 [ "拼音(pinyin)", { STYLE_NORMAL: [["pin"], ["yin"], ["(pinyin)"]], + STYLE_PASSPORT: [["PIN"], ["YIN"], ["(pinyin)"]], STYLE_TONE: [["pīn"], ["yīn"], ["(pinyin)"]], STYLE_TONE2: [["pin1"], ["yin1"], ["(pinyin)"]], STYLE_TO3NE: [["pi1n"], ["yi1n"], ["(pinyin)"]], @@ -180,6 +185,7 @@ const cases: any[] = [ // 中英混合,多音字,单音词。 [ "中国(china)", { STYLE_NORMAL: [["zhong"], ["guo"], ["(china)"]], + STYLE_PASSPORT: [["ZHONG"], ["GUO"], ["(china)"]], STYLE_TONE: { normal: [["zhōng", "zhòng"], ["guó"], ["(china)"]], segment: [["zhōng"], ["guó"], ["(china)"]], @@ -205,6 +211,10 @@ const cases: any[] = [ normal: [["páng", "fǎng"], ["huáng"]], segment: [["páng"], ["huáng"]], }, + STYLE_PASSPORT: { + normal: [["PANG", "FANG"], ["HUANG"]], + segment: [["PANG"], ["HUANG"]], + }, STYLE_TONE2: { normal: [["pang2", "fang3"], ["huang2"]], segment: [["pang2"], ["huang2"]], @@ -226,6 +236,7 @@ const cases: any[] = [ // 中英混合,多音字,单音词。 [ "0套价", { STYLE_NORMAL: [["0"], ["tao"], ["jia", "jie"]], + STYLE_PASSPORT: [["0"], ["TAO"], ["JIA", "JIE"]], STYLE_TONE: [["0"], ["tào"], ["jià", "jiè", "jie"]], STYLE_TONE2: [["0"], ["tao4"], ["jia4", "jie4", "jie"]], STYLE_TO3NE: [["0"], ["ta4o"], ["jia4", "jie4", "jie"]], @@ -239,6 +250,10 @@ const cases: any[] = [ normal: [["nv", "ru"], ["liu"], ["mang", "meng"]], segment: [["nv", "ru"], ["liu"], ["mang"]], }, + STYLE_PASSPORT: { + normal: [["NYU", "RU"], ["LIU"], ["MANG", "MENG"]], + segment: [["NYU", "RU"], ["LIU"], ["MANG"]], + }, STYLE_TONE: { normal: [["nǚ", "rǔ"], ["liú"], ["máng", "méng"]], segment: [["nǚ", "rǔ"], ["liú"], ["máng"]], @@ -273,6 +288,7 @@ describe("姓名模式", function() { it("单姓", function() { expect(pinyin("华夫人", { mode: "NORMAL"})).toEqual([["huá"], ["fū"], ["rén"]]); expect(pinyin("华夫人", { mode: "SURNAME"})).toEqual([["huà"], ["fū"], ["rén"]]); + expect(pinyin("吕布", { mode: "SURNAME", style: "passport" })).toEqual([["LYU"], ["BU"]]); }); });