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:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user