加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
word_matcher_test.go 746 Bytes
一键复制 编辑 原始数据 按行查看 历史
package clickhouse
import (
"testing"
"github.com/stretchr/testify/assert"
)
type wmTest struct {
haystack string
needle string
expect bool
}
func checkMatch(haystack, needle string) bool {
m := newMatcher(needle)
for _, r := range []rune(haystack) {
if m.matchRune(r) {
return true
}
}
return false
}
func TestWordMatcher(t *testing.T) {
table := []wmTest{
wmTest{"select * from test", "select", true},
wmTest{"select * from test", "*", true},
wmTest{"select * from test", "elect", true},
wmTest{"select * from test", "zelect", false},
wmTest{"select * from test", "sElEct", true},
}
for _, test := range table {
assert.Equal(t, checkMatch(test.haystack, test.needle), test.expect, test.haystack)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化