-
Notifications
You must be signed in to change notification settings - Fork 0
/
rand_test.go
66 lines (55 loc) · 992 Bytes
/
rand_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
package hierogolyph
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetRandomBytes(t *testing.T) {
a := assert.New(t)
tests := []struct {
size int
}{
{0},
{1},
{2},
{10},
{100},
{1000},
{10000},
{100000},
}
for _, tt := range tests {
target := fmt.Sprintf("%+v", tt)
result, err := getRandomBytes(tt.size)
a.NoError(err, target)
a.Len(result, tt.size, target)
}
}
func TestGetRandomString(t *testing.T) {
a := assert.New(t)
tests := []struct {
size int
}{
{0},
{1},
{2},
{10},
{100},
{1000},
{10000},
{100000},
}
for _, tt := range tests {
target := fmt.Sprintf("%+v", tt)
result, err := getRandomString(tt.size)
a.NoError(err, target)
a.Len(result, tt.size, target)
}
// confirm all the letter is appeared.
result, err := getRandomString(100000)
a.NoError(err)
for _, letter := range letters {
l := string(letter)
a.Contains(result, l, "cannot find the letter in result", l)
}
}