forked from mojocn/base64Captcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_digit_test.go
102 lines (93 loc) · 2.08 KB
/
item_digit_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
97
98
99
100
101
102
package base64Captcha
import (
"bytes"
"testing"
)
func TestNewItemDigit(t *testing.T) {
type args struct {
width int
height int
dotCount int
maxSkew float64
}
tests := []struct {
name string
args args
want *ItemDigit
}{
{"one", args{240, 80, 6, 0.8}, nil},
{"one", args{240, 80, 5, 0.8}, nil},
{"one", args{240, 80, 6, 0.8}, nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewItemDigit(tt.args.width, tt.args.height, tt.args.dotCount, tt.args.maxSkew); got == nil {
t.Errorf("NewItemDigit() = %v, want %v", got, tt.want)
}
})
}
}
func TestItemDigit_EncodeBinary(t *testing.T) {
idd := NewItemDigit(80, 300, 20, 0.25)
tests := []struct {
name string
m *ItemDigit
want []byte
}{
{"one", idd, nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.m.EncodeBinary(); len(got) == 0 {
t.Errorf("ItemDigit.EncodeBinary() = %v, want %v", got, tt.want)
}
})
}
}
func TestItemDigit_WriteTo(t *testing.T) {
tests := []struct {
name string
m *ItemDigit
want int64
wantW string
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
w := &bytes.Buffer{}
got, err := tt.m.WriteTo(w)
if (err != nil) != tt.wantErr {
t.Errorf("ItemDigit.WriteTo() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("ItemDigit.WriteTo() = %v, want %v", got, tt.want)
}
if gotW := w.String(); gotW != tt.wantW {
t.Errorf("ItemDigit.WriteTo() = %v, want %v", gotW, tt.wantW)
}
})
}
}
func TestItemDigit_EncodeB64string(t *testing.T) {
idd := NewItemDigit(80, 300, 20, 0.25)
tests := []struct {
name string
m *ItemDigit
want string
}{
{"", idd, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.m.EncodeB64string(); got == tt.want {
t.Errorf("ItemDigit.EncodeB64string() = %v, want %v", got, tt.want)
}
})
}
}
func TestItemDigit_DotCountZero(t *testing.T) {
_ = NewItemDigit(80, 300, 0, 0.25)
}