mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-08 06:32:28 +08:00
增加test测试
This commit is contained in:
@@ -329,6 +329,7 @@ func UUIdV4() (string, error) {
|
||||
}
|
||||
|
||||
// RandNumLen 生成一个长度为len的随机数
|
||||
// Play: https://go.dev/play/p/jpIalcD5rMo
|
||||
func RandNumLen(len int) int {
|
||||
m := int(math.Pow10(len) - 1)
|
||||
i := int(math.Pow10(len - 1))
|
||||
|
||||
@@ -3,6 +3,7 @@ package random
|
||||
import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/v2/internal"
|
||||
@@ -361,3 +362,9 @@ func TestRandBoolSlice(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
func TestRandNumLen(t *testing.T) {
|
||||
t.Parallel()
|
||||
randi := RandNumLen(6)
|
||||
assert := internal.NewAssert(t, "TestRandNumLen")
|
||||
assert.Equal(6, len(strconv.Itoa(randi)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user