-
Notifications
You must be signed in to change notification settings - Fork 0
/
captcha_test.go
59 lines (44 loc) · 1.08 KB
/
captcha_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
package captcha_test
import (
"github.com/ErfanMomeniii/captcha.git"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_Numeric_Captcha(t *testing.T) {
c := captcha.New(300, 400, 40)
_, err := c.Numeric(6)
assert.NoError(t, err)
_, err = c.Numeric(100)
assert.NoError(t, err)
}
func Test_Alphabetical_Captcha(t *testing.T) {
c := captcha.New(300, 400, 40)
_, err := c.Alphabetical(6)
assert.NoError(t, err)
_, err = c.Alphabetical(100)
assert.NoError(t, err)
}
func Test_Mixed_Captcha(t *testing.T) {
c := captcha.New(300, 400, 40)
_, err := c.Mixed(6)
assert.NoError(t, err)
_, err = c.Mixed(100)
assert.NoError(t, err)
}
func Test_Save_Image(t *testing.T) {
c := captcha.New(300, 400, 40)
im, err := c.Numeric(6)
assert.NoError(t, err)
err = c.Save("./test/a.png", im)
assert.NoError(t, err)
im, err = c.Alphabetical(6)
assert.NoError(t, err)
err = c.Save("./test/b.png", im)
assert.NoError(t, err)
im, err = c.Mixed(6)
assert.NoError(t, err)
err = c.Save("./test/c.png", im)
assert.NoError(t, err)
err = c.Save("./test/d", im)
assert.NoError(t, err)
}