-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_test.go
More file actions
48 lines (46 loc) · 892 Bytes
/
random_test.go
File metadata and controls
48 lines (46 loc) · 892 Bytes
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
package strings
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestRandom(t *testing.T) {
type args struct {
length int
letters string
}
tests := []struct {
name string
args args
}{
{
name: "must returns random string with length greater-than letters",
args: args{
length: 10,
letters: "QW@#as34",
},
},
{
name: "must returns random string with length less-than letters",
args: args{
length: 5,
letters: "QW@#as34",
},
},
{
name: "must returns random string with length equal letters",
args: args{
length: 8,
letters: "QW@#as34",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rnd := Random(tt.args.length, tt.args.letters)
assert.Equal(t, len(rnd), tt.args.length)
for _, c := range rnd {
assert.Contains(t, tt.args.letters, string(c))
}
})
}
}