mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
refactor: rename package 'utils' to 'internal'
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestRandString(t *testing.T) {
|
||||
@@ -24,7 +24,7 @@ func TestRandString(t *testing.T) {
|
||||
reg := regexp.MustCompile(pattern)
|
||||
|
||||
if len(randStr) != 6 || !reg.MatchString(randStr) {
|
||||
utils.LogFailedTestInfo(t, "RandString", "RandString(6)", "RandString(6) should be 6 letters ", randStr)
|
||||
internal.LogFailedTestInfo(t, "RandString", "RandString(6)", "RandString(6) should be 6 letters ", randStr)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -32,19 +32,19 @@ func TestRandString(t *testing.T) {
|
||||
func TestRandInt(t *testing.T) {
|
||||
res1 := RandInt(1, 10)
|
||||
if res1 < 1 || res1 >= 10 {
|
||||
utils.LogFailedTestInfo(t, "RandInt", "RandInt(1, 10)", "RandInt(1, 10) should between [1, 10) ", res1)
|
||||
internal.LogFailedTestInfo(t, "RandInt", "RandInt(1, 10)", "RandInt(1, 10) should between [1, 10) ", res1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
res2 := RandInt(1, 1)
|
||||
if res2 != 1 {
|
||||
utils.LogFailedTestInfo(t, "RandInt", "RandInt(1, 1)", "RandInt(1, 1) should be 1 ", res2)
|
||||
internal.LogFailedTestInfo(t, "RandInt", "RandInt(1, 1)", "RandInt(1, 1) should be 1 ", res2)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
res3 := RandInt(10, 1)
|
||||
if res3 < 1 || res3 >= 10 {
|
||||
utils.LogFailedTestInfo(t, "RandInt", "RandInt(10, 1)", "RandInt(10, 1) should between [1, 10) ", res3)
|
||||
internal.LogFailedTestInfo(t, "RandInt", "RandInt(10, 1)", "RandInt(10, 1) should between [1, 10) ", res3)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -52,19 +52,19 @@ func TestRandInt(t *testing.T) {
|
||||
func TestRandBytes(t *testing.T) {
|
||||
randBytes := RandBytes(4)
|
||||
if len(randBytes) != 4 {
|
||||
utils.LogFailedTestInfo(t, "RandBytes", "RandBytes(4)", "RandBytes(4) should return 4 element of []bytes", randBytes)
|
||||
internal.LogFailedTestInfo(t, "RandBytes", "RandBytes(4)", "RandBytes(4) should return 4 element of []bytes", randBytes)
|
||||
t.FailNow()
|
||||
}
|
||||
v := reflect.ValueOf(randBytes)
|
||||
et := v.Type().Elem()
|
||||
if v.Kind() != reflect.Slice || et.Kind() != reflect.Uint8 {
|
||||
utils.LogFailedTestInfo(t, "RandBytes", "RandBytes(4)", "RandBytes(4) should return 4 element of []bytes", randBytes)
|
||||
internal.LogFailedTestInfo(t, "RandBytes", "RandBytes(4)", "RandBytes(4) should return 4 element of []bytes", randBytes)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
randErr := RandBytes(0)
|
||||
if randErr != nil {
|
||||
utils.LogFailedTestInfo(t, "RandBytes", "RandBytes(0)", "RandBytes(0) should return nil", randErr)
|
||||
internal.LogFailedTestInfo(t, "RandBytes", "RandBytes(0)", "RandBytes(0) should return nil", randErr)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user