chore: refactor (#2875)

This commit is contained in:
Kevin Wan
2023-02-12 22:20:36 +08:00
committed by kevin
parent 95d7c73409
commit 016d965f56
3 changed files with 49 additions and 30 deletions

View File

@@ -211,3 +211,11 @@ func TestFuzzReplacerCase2(t *testing.T) {
t.Errorf("result: %s, match: %v", val, keys)
}
}
func TestReplacer_ReplaceLongestMatch(t *testing.T) {
replacer := NewReplacer(map[string]string{
"日本的首都": "东京",
"日本": "本日",
})
assert.Equal(t, "东京是东京", replacer.Replace("日本的首都是东京"))
}