-
Notifications
You must be signed in to change notification settings - Fork 55
/
wordmanager_test.go
41 lines (36 loc) · 928 Bytes
/
wordmanager_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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)
}
}
}