mirror of
https://github.com/fumiama/emozi.git
synced 2026-06-08 20:10:27 +08:00
fix(校验): RTL 不可见字符引起的显示问题
This commit is contained in:
@@ -14,8 +14,7 @@ func TestEncode(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(es.String(), lst)
|
||||
if es.String() != "🥛👔🐴👤🌹🐱🐴👩,💦🌞😨🌍➕✌😨👨🌾!😭🔐🍉👁️😭🔐🍉👁️🔪🌀🍉🪩🐑🎵🍉🎵👈🌞😨🚼:[👇🦅🧗⛕|🌹👍🧗⛕]。" {
|
||||
if es.String() != "🥛👔🐴👤🌹🐱🐴👩,💦🌞😨🌍➕👴😨👨🌾!😭🔐🍉👁️😭🔐🍉👁️🔪🌀🍉🪩🐑🎵🍉🎵👈🌞😨🚼:[👇🦅🧗⛕|🌹👍🧗⛕]。" {
|
||||
t.Fatal("got", es.String())
|
||||
}
|
||||
if len(lst) != 1 && lst[0] != 2 {
|
||||
@@ -25,18 +24,16 @@ func TestEncode(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(es.String(), lst)
|
||||
if es.String() != "🥛👔🐴👤🌹🐱🐴👩,💦🌞😨🌍➕✌😨👨🌾!🐽🌞🐴✋🔪🦅😨🏠🔪🌀🍉🪩🐑🎵🍉🎵👈🌞😨🚼:🐑🎵🧗💰🌹👍🧗⛕👇🦅🧗⛕。" {
|
||||
if es.String() != "🥛👔🐴👤🌹🐱🐴👩,💦🌞😨🌍➕👴😨👨🌾!🐽🌞🐴✋🔪🦅😨🏠🔪🌀🍉🪩🐑🎵🍉🎵👈🌞😨🚼:🐑🎵🧗💰🌹👍🧗⛕👇🦅🧗⛕。" {
|
||||
t.Fatal("got", es.String())
|
||||
}
|
||||
if len(lst) != 2 && lst[0] != 2 && lst[1] != 2 {
|
||||
t.Fail()
|
||||
}
|
||||
es, lst, err = c.Encode(false, "的")
|
||||
es, _, err = c.Encode(false, "的")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(es.String(), lst)
|
||||
if es.String() != "的🈳🈳🈳" {
|
||||
t.Fatal("got", es.String())
|
||||
}
|
||||
@@ -48,52 +45,44 @@ func TestDecode(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := "你好,世界!看看多音字:行。"
|
||||
es, lst, err := c.Encode(false, s)
|
||||
es, _, err := c.Encode(false, s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(es.String(), lst)
|
||||
ds, err := c.Decode(es, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(ds)
|
||||
if ds != "[你|儗]好,世[界|畍]!看看多音字:[行|行]。" {
|
||||
t.Fatal("got", ds)
|
||||
}
|
||||
es, lst, err = c.Encode(false, "你好,世界!指定多音字:银行行。", 1, 0)
|
||||
es, _, err = c.Encode(false, "你好,世界!指定多音字:银行行。", 1, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(es.String(), lst)
|
||||
ds, err = c.Decode(es, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(ds)
|
||||
if ds != "[你|儗]好,世[界|畍]![指|抧|扺]定多音字:[銀|银]行行。" {
|
||||
t.Fatal("got", ds)
|
||||
}
|
||||
es, lst, err = c.Encode(false, "好啊")
|
||||
es, _, err = c.Encode(false, "好啊")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(es.String(), lst)
|
||||
ds, err = c.Decode(es, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(ds)
|
||||
if ds != "好啊" {
|
||||
t.Fatal("got", ds)
|
||||
}
|
||||
es = EmoziString("🌹😺🐴👩") // nolint: go-staticcheck
|
||||
t.Log(es.String())
|
||||
es = EmoziString("🌹🐱🐴👩") // nolint: go-staticcheck
|
||||
ds, err = c.Decode(es, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(ds)
|
||||
if ds != "好" {
|
||||
t.Fatal("got", ds)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user