1 Star 0 Fork 12

Doer / gocaptcha

forked from hanguofeng / gocaptcha 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
wordmanager_test.go 928 Bytes
Copy Edit Raw Blame History
hanguofeng authored 2014-01-27 23:36 . update errors
// Copyright 2013 hanguofeng. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gocaptcha
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)
}
}
}
1
https://gitee.com/Doer/gocaptcha.git
git@gitee.com:Doer/gocaptcha.git
Doer
gocaptcha
gocaptcha
master

Search