chore: add more tests (#2866)
* chore: add more tests * chore: add more tests * chore: fix test failure
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user