chore: add more tests (#2866)

* chore: add more tests

* chore: add more tests

* chore: fix test failure
This commit is contained in:
Kevin Wan
2023-02-11 14:21:39 +08:00
committed by kevin
parent 89f841c126
commit 04f181f0b4
6 changed files with 48 additions and 6 deletions

View File

@@ -60,6 +60,22 @@ func TestReplacer_ReplaceLongestMatching(t *testing.T) {
assert.Equal(t, "东京在japan", replacer.Replace("日本的首都在日本"))
}
func TestReplacer_ReplaceLongestOverlap(t *testing.T) {
keywords := map[string]string{
"456": "def",
"abcd": "1234",
}
replacer := NewReplacer(keywords)
assert.Equal(t, "123def7", replacer.Replace("abcd567"))
}
func TestReplacer_ReplaceLongestLonger(t *testing.T) {
mapping := map[string]string{
"c": "3",
}
assert.Equal(t, "3d", NewReplacer(mapping).Replace("cd"))
}
func TestReplacer_ReplaceJumpToFail(t *testing.T) {
mapping := map[string]string{
"bcdf": "1235",