-
Notifications
You must be signed in to change notification settings - Fork 0
/
gorax_suite_test.go
52 lines (45 loc) · 1.02 KB
/
gorax_suite_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
package gorax_test
import (
"math/rand"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestGorax(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Gorax Test Suite")
}
func randString(n int) string {
letters := [][]rune{
[]rune("abc"),
[]rune("abcdefghijklmnopqrstuvwxyz"),
[]rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
[]rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+{}:\\|\"<>?/.,';][=-'"),
}
runes := letters[rand.Intn(len(letters))]
r := make([]rune, n)
for i := range r {
r[i] = runes[rand.Intn(len(runes))]
}
return string(r)
}
func randInteface() interface{} {
funcs := []func() interface{}{
func() interface{} {
return rand.Int()
},
func() interface{} {
return nil
},
func() interface{} {
return []bool{true, false}[rand.Intn(2)]
},
func() interface{} {
return randString(10)
},
func() interface{} {
return struct{ foo string }{"bar"}
},
}
return funcs[rand.Intn(len(funcs))]()
}