加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wordmanager_test.go 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
shirdon 提交于 2019-07-07 16:16 . commit
//++++++++++++++++++++++++++++++++++++++++
//Fighting for great,share generate value!
//Build the best soft by golang,let's go!
//++++++++++++++++++++++++++++++++++++++++
//Author:ShirDon <http://www.shirdon.com>
//Email:hcbsts@163.com; 823923263@qq.com
//++++++++++++++++++++++++++++++++++++++++
package captchas_with_go
import (
"os"
"testing"
)
func TestWordManager(t *testing.T) {
pwd, err := os.Getwd()
if (nil != err) || "" == pwd {
return
}
path := pwd + "/data/"
singleCharDict := []string{"cn_char", "en_char"}
phrasesDict := []string{"cn_phrases", "en_phrases"}
length := 6
for _, f := range singleCharDict {
mgr, err := CreateWordManagerFromDataFile(path + f)
s, err := mgr.Get(length)
if nil != err {
t.Errorf(err.Error())
} else if length != len([]rune(s)) {
t.Errorf("get no equals length:" + f)
}
}
for _, f := range phrasesDict {
mgr, err := CreateWordManagerFromDataFile(path + f)
s, err := mgr.Get(length)
if nil != err {
t.Errorf(err.Error())
} else if 0 >= len([]rune(s)) {
t.Errorf("not get:" + f)
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化