-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathrandom_test.go
41 lines (32 loc) · 1.02 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
package utils
import "testing"
func TestRandomString(t *testing.T) {
length := 10
randomStr := RandomString(length)
if len(randomStr) != length {
t.Errorf("Expected random string length %d, but got %d", length, len(randomStr))
}
}
func TestRandomStringWithAlphabet(t *testing.T) {
length := 15
alphabet := "ABC123"
randomStr := RandomStringWithAlphabet(length, alphabet)
if len(randomStr) != length {
t.Errorf("Expected random string length %d, but got %d", length, len(randomStr))
}
}
func TestPseudorandomString(t *testing.T) {
length := 20
pseudoRandomStr := PseudorandomString(length)
if len(pseudoRandomStr) != length {
t.Errorf("Expected pseudorandom string length %d, but got %d", length, len(pseudoRandomStr))
}
}
func TestPseudorandomStringWithAlphabet(t *testing.T) {
length := 25
alphabet := "xyz789"
pseudoRandomStr := PseudorandomStringWithAlphabet(length, alphabet)
if len(pseudoRandomStr) != length {
t.Errorf("Expected pseudorandom string length %d, but got %d", length, len(pseudoRandomStr))
}
}