gocron/modules/utils/utils_test.go

25 lines
539 B
Go
Raw Normal View History

2017-03-23 01:59:00 +00:00
package utils
import "testing"
func TestRandString(t *testing.T) {
2017-04-02 02:38:49 +00:00
str := RandString(32)
if len(str) != 32 {
t.Fatalf("长度不匹配,目标长度32, 实际%d-%s", len(str), str)
}
2017-03-23 01:59:00 +00:00
}
func TestMd5(t *testing.T) {
2017-04-02 02:38:49 +00:00
str := Md5("123456")
if len(str) != 32 {
t.Fatalf("长度不匹配,目标长度32, 实际%d-%s", len(str), str)
}
2017-03-23 01:59:00 +00:00
}
func TestRandNumber(t *testing.T) {
2017-04-02 02:38:49 +00:00
num := RandNumber(10000)
if num <= 0 && num >= 10000 {
t.Fatalf("随机数不在有效范围内-%d", num)
}
2017-04-02 02:19:52 +00:00
}