forked from mojocn/base64Captcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver_language_test.go
96 lines (89 loc) · 2.41 KB
/
driver_language_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package base64Captcha
import (
"image/color"
"reflect"
"testing"
"github.com/golang/freetype/truetype"
)
func TestDriverLanguage_DrawCaptcha(t *testing.T) {
ds := NewDriverLanguage(80, 240, 5, OptionShowSineLine|OptionShowSlimeLine|OptionShowHollowLine, 5, nil, nil, []*truetype.Font{fontChinese}, "emotion")
for i := 0; i < 40; i++ {
_, q, _ := ds.GenerateIdQuestionAnswer()
item, err := ds.DrawCaptcha(q)
if err != nil {
t.Error(err)
}
itemWriteFile(item, "_builds", RandomId(), "png")
}
}
func Test_generateRandomRune(t *testing.T) {
type args struct {
size int
code string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := generateRandomRune(tt.args.size, tt.args.code); got != tt.want {
t.Errorf("generateRandomRune() = %v, want %v", got, tt.want)
}
})
}
}
func TestNewDriverLanguage(t *testing.T) {
type args struct {
height int
width int
noiseCount int
showLineOptions int
length int
bgColor *color.RGBA
fonts []*truetype.Font
languageCode string
}
tests := []struct {
name string
args args
want *DriverLanguage
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewDriverLanguage(tt.args.height, tt.args.width, tt.args.noiseCount, tt.args.showLineOptions, tt.args.length, tt.args.bgColor, nil, tt.args.fonts, tt.args.languageCode); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewDriverLanguage() = %v, want %v", got, tt.want)
}
})
}
}
func TestDriverLanguage_GenerateIdQuestionAnswer(t *testing.T) {
tests := []struct {
name string
d *DriverLanguage
wantId string
wantContent string
wantAnswer string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotId, gotContent, gotAnswer := tt.d.GenerateIdQuestionAnswer()
if gotId != tt.wantId {
t.Errorf("DriverLanguage.GenerateIdQuestionAnswer() gotId = %v, want %v", gotId, tt.wantId)
}
if gotContent != tt.wantContent {
t.Errorf("DriverLanguage.GenerateIdQuestionAnswer() gotContent = %v, want %v", gotContent, tt.wantContent)
}
if gotAnswer != tt.wantAnswer {
t.Errorf("DriverLanguage.GenerateIdQuestionAnswer() gotAnswer = %v, want %v", gotAnswer, tt.wantAnswer)
}
})
}
}