-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_test.go
36 lines (32 loc) · 944 Bytes
/
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
package foxkit
import "testing"
func TestRandomString(t *testing.T) {
random, err := RandomString(20)
if err != nil {
t.Errorf("Generating random string failed: %s", err.Error())
}
// check if a single string matches
match, err := RandomStringCompare(&random, &random)
if err != nil {
t.Errorf("Generating random string failed: %s", err.Error())
}
if !match {
t.Error("The same generated string didn't match")
}
// check if two separate strings match
randomOne, err := RandomString(30)
if err != nil {
t.Errorf("Generating random string failed: %s", err.Error())
}
randomTwo, err := RandomString(30)
if err != nil {
t.Errorf("Generating random string failed: %s", err.Error())
}
match, err = RandomStringCompare(&randomOne, &randomTwo)
if err != nil {
t.Errorf("Generating random string failed: %s", err.Error())
}
if match {
t.Errorf("Two generated strings matched: %s and %s", randomOne, randomTwo)
}
}