Files

41 lines
616 B
Go
Raw Permalink Normal View History

2024-01-11 22:19:02 +08:00
package randomx_test
import (
"testing"
"code.yun.ink/pkg/randomx"
)
2024-11-01 23:36:05 +08:00
func TestRandomRune(t *testing.T) {
str, err := randomx.RandomRune(20)
2024-01-11 22:19:02 +08:00
if err != nil {
t.Fatal(err.Error())
}
2024-11-01 23:36:05 +08:00
t.Log(str)
2024-01-11 22:19:02 +08:00
}
func TestRandomStr(t *testing.T) {
str, err := randomx.RandomStr(10)
if err != nil {
t.Fatal(err.Error())
}
if len(str) == 10 {
t.Log("正常")
2024-11-01 23:36:05 +08:00
t.Log(str)
2024-01-11 22:19:02 +08:00
} else {
t.Fatal("不正常", str)
}
}
2024-11-01 23:36:05 +08:00
func TestRandomInt(t *testing.T) {
i, err := randomx.RandomInt(100, 101)
if err != nil {
t.Fatal(err.Error())
}
if i >= 100 && i <= 101 {
t.Log("正常")
} else {
t.Fatal("不正常", i)
}
}