1
0
mirror of https://github.com/fumiama/emozi.git synced 2026-06-11 05:30:35 +08:00

optimize(db): add memory cache & mutex

This commit is contained in:
源文雨
2024-02-14 20:57:19 +09:00
parent ceb7686da6
commit 76dca88501
4 changed files with 82 additions and 23 deletions

View File

@@ -10,20 +10,26 @@ func TestEncode(t *testing.T) {
if err != nil {
t.Fatal(err)
}
es, err := c.Encode("你好,世界!看看多音字:行。")
es, lst, err := c.Encode("你好,世界!看看多音字:行。")
if err != nil {
t.Fatal(err)
}
t.Log(es.String())
t.Log(es.String(), lst)
if es.String() != "🥛👔🐴👤🌹🐱🐴👩,💦🌞😨🌍➕✌😨👨‍🌾!😭🔐🍉👁️😭🔐🍉👁️🔪🌀🍉🪩🐑🎵🍉🎵👈🌞😨🚼:[👇🦅🧗⛕|🌹👍🧗⛕]。" {
t.Fatal("got", es.String())
}
es, err = c.Encode("你好,世界!指定多音字:银行行。", 1, 0)
if len(lst) != 1 && lst[0] != 2 {
t.Fail()
}
es, lst, err = c.Encode("你好,世界!指定多音字:银行行。", 1, 0)
if err != nil {
t.Fatal(err)
}
t.Log(es.String())
t.Log(es.String(), lst)
if es.String() != "🥛👔🐴👤🌹🐱🐴👩,💦🌞😨🌍➕✌😨👨‍🌾!🐽🌞🐴✋🔪🦅😨🏠🔪🌀🍉🪩🐑🎵🍉🎵👈🌞😨🚼:🐑🎵🧗💰🌹👍🧗⛕👇🦅🧗⛕。" {
t.Fatal("got", es.String())
}
if len(lst) != 2 && lst[0] != 2 && lst[1] != 2 {
t.Fail()
}
}