添加随机数

This commit is contained in:
Yun
2024-11-01 23:36:05 +08:00
parent 591620e532
commit a056d5eba1
2 changed files with 39 additions and 12 deletions
+21 -12
View File
@@ -6,6 +6,27 @@ import (
"code.yun.ink/pkg/randomx"
)
func TestRandomRune(t *testing.T) {
str, err := randomx.RandomRune(20)
if err != nil {
t.Fatal(err.Error())
}
t.Log(str)
}
func TestRandomStr(t *testing.T) {
str, err := randomx.RandomStr(10)
if err != nil {
t.Fatal(err.Error())
}
if len(str) == 10 {
t.Log("正常")
t.Log(str)
} else {
t.Fatal("不正常", str)
}
}
func TestRandomInt(t *testing.T) {
i, err := randomx.RandomInt(100, 101)
if err != nil {
@@ -17,15 +38,3 @@ func TestRandomInt(t *testing.T) {
t.Fatal("不正常", i)
}
}
func TestRandomStr(t *testing.T) {
str, err := randomx.RandomStr(10)
if err != nil {
t.Fatal(err.Error())
}
if len(str) == 10 {
t.Log("正常")
} else {
t.Fatal("不正常", str)
}
}