-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrandom_test.go
53 lines (48 loc) · 1.12 KB
/
random_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
package stubs
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGenerators_Characters(t *testing.T) {
gen, err := newGenerator("")
if assert.NoError(t, err) {
opts := &simpleOpts{name: "characters"}
fn, found := gen.For(opts)
if assert.True(t, found) {
res, err := fn(opts)
if assert.NoError(t, err) {
assert.IsType(t, "", res)
assert.Len(t, res, 10)
}
opts.args = append(opts.args, 15)
res, err = fn(opts)
if assert.NoError(t, err) {
assert.IsType(t, "", res)
assert.Len(t, res, 15)
}
}
}
}
func TestGeneratorsBool(t *testing.T) {
gen, err := newGenerator("")
if assert.NoError(t, err) {
boolfn, found := gen.For(&simpleOpts{name: "bool"})
if assert.True(t, found) {
for i := 0; i < 64; i++ {
result, err := boolfn(new(simpleOpts))
if assert.NoError(t, err) {
assert.IsType(t, true, result)
}
}
}
boolfn, found = gen.For(&simpleOpts{name: "boolean"})
if assert.True(t, found) {
for i := 0; i < 32; i++ {
result, err := boolfn(new(simpleOpts))
if assert.NoError(t, err) {
assert.IsType(t, true, result)
}
}
}
}
}