mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-08 06:32:28 +08:00
refactor: rename package 'utils' to 'internal'
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestToChar(t *testing.T) {
|
||||
@@ -18,7 +18,7 @@ func TestToChar(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := ToChar(cases[i])
|
||||
if !reflect.DeepEqual(res, expected[i]) {
|
||||
utils.LogFailedTestInfo(t, "ToChar", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "ToChar", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func TestToBool(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res, _ := ToBool(cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "ToBool", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "ToBool", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func TestToBytes(t *testing.T) {
|
||||
res, _ := ToBytes(cases[i])
|
||||
fmt.Println(res)
|
||||
if !reflect.DeepEqual(res, expected[i]) {
|
||||
utils.LogFailedTestInfo(t, "ToBytes", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "ToBytes", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func TestToInt(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res, _ := ToInt(cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "ToInt", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "ToInt", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func TestToFloat(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res, _ := ToFloat(cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "ToFloat", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "ToFloat", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func TestToString(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := ToString(cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "ToString", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "ToString", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func TestToJson(t *testing.T) {
|
||||
mapJson := "{\"a\":1,\"b\":2,\"c\":3}"
|
||||
r1, _ := ToJson(aMap)
|
||||
if r1 != mapJson {
|
||||
utils.LogFailedTestInfo(t, "ToJson", aMap, mapJson, r1)
|
||||
internal.LogFailedTestInfo(t, "ToJson", aMap, mapJson, r1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestToJson(t *testing.T) {
|
||||
structJson := "{\"Name\":\"TestStruct\"}"
|
||||
r2, _ := ToJson(aStruct)
|
||||
if r2 != structJson {
|
||||
utils.LogFailedTestInfo(t, "ToJson", aMap, mapJson, r1)
|
||||
internal.LogFailedTestInfo(t, "ToJson", aMap, mapJson, r1)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func TestStructToMap(t *testing.T) {
|
||||
//exp1["100"] = 100
|
||||
|
||||
if !reflect.DeepEqual(pm1, m1) {
|
||||
utils.LogFailedTestInfo(t, "StructToMap", p1, m1, pm1)
|
||||
internal.LogFailedTestInfo(t, "StructToMap", p1, m1, pm1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestStructToMap(t *testing.T) {
|
||||
m2["100"] = 100
|
||||
|
||||
if reflect.DeepEqual(pm2, m2) {
|
||||
utils.LogFailedTestInfo(t, "StructToMap", p2, m2, pm2)
|
||||
internal.LogFailedTestInfo(t, "StructToMap", p2, m2, pm2)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ func TestColorHexToRGB(t *testing.T) {
|
||||
expected := "0,51,102"
|
||||
|
||||
if colorRGB != expected {
|
||||
utils.LogFailedTestInfo(t, "ColorHexToRGB", colorHex, expected, colorRGB)
|
||||
internal.LogFailedTestInfo(t, "ColorHexToRGB", colorHex, expected, colorRGB)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ func TestColorRGBToHex(t *testing.T) {
|
||||
expected := "#003366"
|
||||
|
||||
if colorHex != expected {
|
||||
utils.LogFailedTestInfo(t, "ColorHexToRGB", colorRGB, expected, colorHex)
|
||||
internal.LogFailedTestInfo(t, "ColorHexToRGB", colorRGB, expected, colorHex)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package cryptor
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestAesEcbEncrypt(t *testing.T) {
|
||||
@@ -14,7 +14,7 @@ func TestAesEcbEncrypt(t *testing.T) {
|
||||
aesEcbDecrypt := AesEcbDecrypt(aesEcbEncrypt, []byte(key))
|
||||
|
||||
if string(aesEcbDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "AesEcbEncrypt/AesEcbDecrypt", data, data, string(aesEcbDecrypt))
|
||||
internal.LogFailedTestInfo(t, "AesEcbEncrypt/AesEcbDecrypt", data, data, string(aesEcbDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func TestAesCbcEncrypt(t *testing.T) {
|
||||
aesCbcDecrypt := AesCbcDecrypt(aesCbcEncrypt, []byte(key))
|
||||
|
||||
if string(aesCbcDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "AesCbcEncrypt/AesCbcDecrypt", data, data, string(aesCbcDecrypt))
|
||||
internal.LogFailedTestInfo(t, "AesCbcEncrypt/AesCbcDecrypt", data, data, string(aesCbcDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestAesCtrCrypt(t *testing.T) {
|
||||
aesCtrDeCrypt := AesCtrCrypt(aesCtrCrypt, []byte(key))
|
||||
|
||||
if string(aesCtrDeCrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "AesCtrCrypt", data, data, string(aesCtrDeCrypt))
|
||||
internal.LogFailedTestInfo(t, "AesCtrCrypt", data, data, string(aesCtrDeCrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ func TestAesCfbEncrypt(t *testing.T) {
|
||||
aesCfbDecrypt := AesCfbDecrypt(aesCfbEncrypt, []byte(key))
|
||||
|
||||
if string(aesCfbDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "AesCfbEncrypt/AesCfbDecrypt", data, data, string(aesCfbDecrypt))
|
||||
internal.LogFailedTestInfo(t, "AesCfbEncrypt/AesCfbDecrypt", data, data, string(aesCfbDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func TestAesOfbEncrypt(t *testing.T) {
|
||||
aesOfbDecrypt := AesOfbDecrypt(aesOfbEncrypt, []byte(key))
|
||||
|
||||
if string(aesOfbDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "AesOfbEncrypt/AesOfbDecrypt", data, data, string(aesOfbDecrypt))
|
||||
internal.LogFailedTestInfo(t, "AesOfbEncrypt/AesOfbDecrypt", data, data, string(aesOfbDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestBase64StdEncode(t *testing.T) {
|
||||
@@ -13,7 +13,7 @@ func TestBase64StdEncode(t *testing.T) {
|
||||
bs := Base64StdEncode(s)
|
||||
|
||||
if bs != "aGVsbG8gd29ybGQ=" {
|
||||
utils.LogFailedTestInfo(t, "Base64StdEncode", s, "aGVsbG8gd29ybGQ=", bs)
|
||||
internal.LogFailedTestInfo(t, "Base64StdEncode", s, "aGVsbG8gd29ybGQ=", bs)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func TestBase64StdDecode(t *testing.T) {
|
||||
s := Base64StdDecode(bs)
|
||||
|
||||
if s != "hello world" {
|
||||
utils.LogFailedTestInfo(t, "Base64StdDecode", bs, "hello world=", s)
|
||||
internal.LogFailedTestInfo(t, "Base64StdDecode", bs, "hello world=", s)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func TestMd5String(t *testing.T) {
|
||||
expected := "5d41402abc4b2a76b9719d911017c592"
|
||||
|
||||
if smd5 != expected {
|
||||
utils.LogFailedTestInfo(t, "Md5String", s, expected, smd5)
|
||||
internal.LogFailedTestInfo(t, "Md5String", s, expected, smd5)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func TestHmacMd5(t *testing.T) {
|
||||
expected := "5f4c9faaff0a1ad3007d9ddc06abe36d"
|
||||
|
||||
if hmacMd5 != expected {
|
||||
utils.LogFailedTestInfo(t, "HmacMd5", s, expected, hmacMd5)
|
||||
internal.LogFailedTestInfo(t, "HmacMd5", s, expected, hmacMd5)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func TestHmacSha1(t *testing.T) {
|
||||
expected := "3826f812255d8683f051ee97346d1359234d5dbd"
|
||||
|
||||
if hmacSha1 != expected {
|
||||
utils.LogFailedTestInfo(t, "HmacSha1", s, expected, hmacSha1)
|
||||
internal.LogFailedTestInfo(t, "HmacSha1", s, expected, hmacSha1)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func TestHmacSha256(t *testing.T) {
|
||||
expected := "9dce2609f2d67d41f74c7f9efc8ccd44370d41ad2de52982627588dfe7289ab8"
|
||||
|
||||
if hmacSha256 != expected {
|
||||
utils.LogFailedTestInfo(t, "HmacSha256", s, expected, hmacSha256)
|
||||
internal.LogFailedTestInfo(t, "HmacSha256", s, expected, hmacSha256)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func TestHmacSha512(t *testing.T) {
|
||||
expected := "5b1563ac4e9b49c9ada8ccb232588fc4f0c30fd12f756b3a0b95af4985c236ca60925253bae10ce2c6bf9af1c1679b51e5395ff3d2826c0a2c7c0d72225d4175"
|
||||
|
||||
if hmacSha512 != expected {
|
||||
utils.LogFailedTestInfo(t, "HmacSha512", s, expected, hmacSha512)
|
||||
internal.LogFailedTestInfo(t, "HmacSha512", s, expected, hmacSha512)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func TestSha1(t *testing.T) {
|
||||
expected := "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"
|
||||
|
||||
if sha1 != expected {
|
||||
utils.LogFailedTestInfo(t, "Sha1", s, expected, sha1)
|
||||
internal.LogFailedTestInfo(t, "Sha1", s, expected, sha1)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func TestSha256(t *testing.T) {
|
||||
expected := "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
|
||||
|
||||
if sha256 != expected {
|
||||
utils.LogFailedTestInfo(t, "Sha256", s, expected, sha256)
|
||||
internal.LogFailedTestInfo(t, "Sha256", s, expected, sha256)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func TestSha512(t *testing.T) {
|
||||
expected := "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f"
|
||||
|
||||
if sha512 != expected {
|
||||
utils.LogFailedTestInfo(t, "Sha512", s, expected, sha512)
|
||||
internal.LogFailedTestInfo(t, "Sha512", s, expected, sha512)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package cryptor
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestDesEcbEncrypt(t *testing.T) {
|
||||
@@ -14,7 +14,7 @@ func TestDesEcbEncrypt(t *testing.T) {
|
||||
desEcbDecrypt := DesEcbDecrypt(desEcbEncrypt, []byte(key))
|
||||
|
||||
if string(desEcbDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "DesEcbEncrypt/DesEcbDecrypt", data, data, string(desEcbDecrypt))
|
||||
internal.LogFailedTestInfo(t, "DesEcbEncrypt/DesEcbDecrypt", data, data, string(desEcbDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func TestDesCbcEncrypt(t *testing.T) {
|
||||
desCbcDecrypt := DesCbcDecrypt(desCbcEncrypt, []byte(key))
|
||||
|
||||
if string(desCbcDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "DesCbcEncrypt/DesCbcDecrypt", data, data, string(desCbcDecrypt))
|
||||
internal.LogFailedTestInfo(t, "DesCbcEncrypt/DesCbcDecrypt", data, data, string(desCbcDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestDesCtrCrypt(t *testing.T) {
|
||||
desCtrDeCrypt := DesCtrCrypt(desCtrCrypt, []byte(key))
|
||||
|
||||
if string(desCtrDeCrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "DesCtrCrypt", data, data, string(desCtrDeCrypt))
|
||||
internal.LogFailedTestInfo(t, "DesCtrCrypt", data, data, string(desCtrDeCrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ func TestDesCfbEncrypt(t *testing.T) {
|
||||
desCfbDecrypt := DesCfbDecrypt(desCfbEncrypt, []byte(key))
|
||||
|
||||
if string(desCfbDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "DesCfbEncrypt/DesCfbDecrypt", data, data, string(desCfbDecrypt))
|
||||
internal.LogFailedTestInfo(t, "DesCfbEncrypt/DesCfbDecrypt", data, data, string(desCfbDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func TestDesOfbEncrypt(t *testing.T) {
|
||||
desOfbDecrypt := DesOfbDecrypt(desOfbEncrypt, []byte(key))
|
||||
|
||||
if string(desOfbDecrypt) != data {
|
||||
utils.LogFailedTestInfo(t, "DesOfbEncrypt/DesOfbDecrypt", data, data, string(desOfbDecrypt))
|
||||
internal.LogFailedTestInfo(t, "DesOfbEncrypt/DesOfbDecrypt", data, data, string(desOfbDecrypt))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package cryptor
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestRsaEncrypt(t *testing.T) {
|
||||
@@ -13,7 +13,7 @@ func TestRsaEncrypt(t *testing.T) {
|
||||
decrypted := RsaDecrypt(encrypted, "rsa_private.pem")
|
||||
|
||||
if string(data) != string(decrypted) {
|
||||
utils.LogFailedTestInfo(t, "RsaEncrypt/RsaDecrypt", string(data), string(data), string(decrypted))
|
||||
internal.LogFailedTestInfo(t, "RsaEncrypt/RsaDecrypt", string(data), string(data), string(decrypted))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package datetime
|
||||
|
||||
import (
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -12,14 +12,14 @@ func TestAddDay(t *testing.T) {
|
||||
after2Days := AddDay(now, 2)
|
||||
diff1 := after2Days.Sub(now)
|
||||
if diff1.Hours() != 48 {
|
||||
utils.LogFailedTestInfo(t, "AddDay", now, 48, diff1.Hours())
|
||||
internal.LogFailedTestInfo(t, "AddDay", now, 48, diff1.Hours())
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
before2Days := AddDay(now, -2)
|
||||
diff2 := before2Days.Sub(now)
|
||||
if diff2.Hours() != -48 {
|
||||
utils.LogFailedTestInfo(t, "AddDay", now, -48, diff2.Hours())
|
||||
internal.LogFailedTestInfo(t, "AddDay", now, -48, diff2.Hours())
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ func TestAddHour(t *testing.T) {
|
||||
after2Hours := AddHour(now, 2)
|
||||
diff1 := after2Hours.Sub(now)
|
||||
if diff1.Hours() != 2 {
|
||||
utils.LogFailedTestInfo(t, "AddHour", now, 2, diff1.Hours())
|
||||
internal.LogFailedTestInfo(t, "AddHour", now, 2, diff1.Hours())
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
before2Hours := AddHour(now, -2)
|
||||
diff2 := before2Hours.Sub(now)
|
||||
if diff2.Hours() != -2 {
|
||||
utils.LogFailedTestInfo(t, "AddHour", now, -2, diff2.Hours())
|
||||
internal.LogFailedTestInfo(t, "AddHour", now, -2, diff2.Hours())
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -48,14 +48,14 @@ func TestAddMinute(t *testing.T) {
|
||||
after2Minutes := AddMinute(now, 2)
|
||||
diff1 := after2Minutes.Sub(now)
|
||||
if diff1.Minutes() != 2 {
|
||||
utils.LogFailedTestInfo(t, "AddMinute", now, 2, diff1.Minutes())
|
||||
internal.LogFailedTestInfo(t, "AddMinute", now, 2, diff1.Minutes())
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
before2Minutes := AddMinute(now, -2)
|
||||
diff2 := before2Minutes.Sub(now)
|
||||
if diff2.Minutes() != -2 {
|
||||
utils.LogFailedTestInfo(t, "AddMinute", now, -2, diff2.Minutes())
|
||||
internal.LogFailedTestInfo(t, "AddMinute", now, -2, diff2.Minutes())
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func TestGetNowDate(t *testing.T) {
|
||||
date := GetNowDate()
|
||||
expected := time.Now().Format("2006-01-02")
|
||||
if date != expected {
|
||||
utils.LogFailedTestInfo(t, "GetNowDate", "", expected, date)
|
||||
internal.LogFailedTestInfo(t, "GetNowDate", "", expected, date)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func TestGetNotTime(t *testing.T) {
|
||||
ts := GetNowTime()
|
||||
expected := time.Now().Format("15:04:05")
|
||||
if ts != expected {
|
||||
utils.LogFailedTestInfo(t, "GetNowTime", "", expected, ts)
|
||||
internal.LogFailedTestInfo(t, "GetNowTime", "", expected, ts)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func TestGetNowDateTime(t *testing.T) {
|
||||
ts := GetNowDateTime()
|
||||
expected := time.Now().Format("2006-01-02 15:04:05")
|
||||
if ts != expected {
|
||||
utils.LogFailedTestInfo(t, "GetNowDateTime", "", expected, ts)
|
||||
internal.LogFailedTestInfo(t, "GetNowDateTime", "", expected, ts)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func TestFormatTimeToStr(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := FormatTimeToStr(datetime, cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "FormatTimeToStr", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "FormatTimeToStr", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func TestFormatStrToTime(t *testing.T) {
|
||||
}
|
||||
expected, _ := time.Parse(formats[i], datetimeStr[i])
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "FormatTimeToStr", cases[i], expected, res)
|
||||
internal.LogFailedTestInfo(t, "FormatTimeToStr", cases[i], expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestIsExist(t *testing.T) {
|
||||
@@ -15,7 +15,7 @@ func TestIsExist(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := IsExist(cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "IsExist", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "IsExist", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -26,15 +26,15 @@ func TestCreateFile(t *testing.T) {
|
||||
if CreateFile(f) {
|
||||
file, err := os.Open(f)
|
||||
if err != nil {
|
||||
utils.LogFailedTestInfo(t, "CreateFile", f, f, "create file error: "+err.Error())
|
||||
internal.LogFailedTestInfo(t, "CreateFile", f, f, "create file error: "+err.Error())
|
||||
t.FailNow()
|
||||
}
|
||||
if file.Name() != f {
|
||||
utils.LogFailedTestInfo(t, "CreateFile", f, f, file.Name())
|
||||
internal.LogFailedTestInfo(t, "CreateFile", f, f, file.Name())
|
||||
t.FailNow()
|
||||
}
|
||||
} else {
|
||||
utils.LogFailedTestInfo(t, "CreateFile", f, f, "create file error")
|
||||
internal.LogFailedTestInfo(t, "CreateFile", f, f, "create file error")
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func TestIsDir(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := IsDir(cases[i])
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "IsDir", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "IsDir", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -57,11 +57,11 @@ func TestRemoveFile(t *testing.T) {
|
||||
if CreateFile(f) {
|
||||
err := RemoveFile(f)
|
||||
if err != nil {
|
||||
utils.LogFailedTestInfo(t, "RemoveFile", f, f, err.Error())
|
||||
internal.LogFailedTestInfo(t, "RemoveFile", f, f, err.Error())
|
||||
t.FailNow()
|
||||
}
|
||||
} else {
|
||||
utils.LogFailedTestInfo(t, "RemoveFile", f, f, "create file error")
|
||||
internal.LogFailedTestInfo(t, "RemoveFile", f, f, "create file error")
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -76,11 +76,11 @@ func TestCopyFile(t *testing.T) {
|
||||
if err != nil {
|
||||
file, err := os.Open(dstFile)
|
||||
if err != nil {
|
||||
utils.LogFailedTestInfo(t, "CopyFile", srcFile, dstFile, "create file error: "+err.Error())
|
||||
internal.LogFailedTestInfo(t, "CopyFile", srcFile, dstFile, "create file error: "+err.Error())
|
||||
t.FailNow()
|
||||
}
|
||||
if file.Name() != dstFile {
|
||||
utils.LogFailedTestInfo(t, "CopyFile", srcFile, dstFile, file.Name())
|
||||
internal.LogFailedTestInfo(t, "CopyFile", srcFile, dstFile, file.Name())
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestListFileNames(t *testing.T) {
|
||||
}
|
||||
expected := []string{"datetime.go", "datetime_test.go"}
|
||||
if !reflect.DeepEqual(filesInCurrentPath, expected) {
|
||||
utils.LogFailedTestInfo(t, "ToChar", "./", expected, filesInCurrentPath)
|
||||
internal.LogFailedTestInfo(t, "ToChar", "./", expected, filesInCurrentPath)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func TestReadFileToString(t *testing.T) {
|
||||
|
||||
res, _ := ReadFileToString(path)
|
||||
if res != "hello world" {
|
||||
utils.LogFailedTestInfo(t, "ReadFileToString", path, "hello world", res)
|
||||
internal.LogFailedTestInfo(t, "ReadFileToString", path, "hello world", res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func TestClearFile(t *testing.T) {
|
||||
|
||||
res, _ := ReadFileToString(path)
|
||||
if res != "" {
|
||||
utils.LogFailedTestInfo(t, "CreateFile", path, "", res)
|
||||
internal.LogFailedTestInfo(t, "CreateFile", path, "", res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,6 @@ func TestReadFileByLine(t *testing.T) {
|
||||
expected := []string{"hello", "world"}
|
||||
res, _ := ReadFileByLine(path)
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "ReadFileByLine", path, expected, res)
|
||||
internal.LogFailedTestInfo(t, "ReadFileByLine", path, expected, res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package formatter
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestComma(t *testing.T) {
|
||||
@@ -22,7 +22,7 @@ func TestComma(t *testing.T) {
|
||||
func comma(t *testing.T, test interface{}, symbol string, expected interface{}) {
|
||||
res := Comma(test, symbol)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "Comma", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "Comma", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2021 dudaodong@gmail.com. All rights reserved.
|
||||
// Use of this source code is governed by MIT license
|
||||
|
||||
// Package utils implements is for internal use.
|
||||
package utils
|
||||
// Package internal is for internal use.
|
||||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestGetInternalIp(t *testing.T) {
|
||||
internalIp := GetInternalIp()
|
||||
ip := net.ParseIP(internalIp)
|
||||
if ip == nil {
|
||||
utils.LogFailedTestInfo(t, "GetInternalIp", "GetInternalIp", "", ip)
|
||||
internal.LogFailedTestInfo(t, "GetInternalIp", "GetInternalIp", "", ip)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestIsPublicIP(t *testing.T) {
|
||||
res := IsPublicIP(ips[i])
|
||||
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "IsPublicIP", ips[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "IsPublicIP", ips[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestHttpGet(t *testing.T) {
|
||||
@@ -112,7 +112,7 @@ func TestConvertMapToQueryString(t *testing.T) {
|
||||
expected := "a=1&b=2&c=3"
|
||||
r := ConvertMapToQueryString(m)
|
||||
if r != expected {
|
||||
utils.LogFailedTestInfo(t, "ConvertMapToQueryString", m, expected, r)
|
||||
internal.LogFailedTestInfo(t, "ConvertMapToQueryString", m, expected, r)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestContain(t *testing.T) {
|
||||
@@ -28,7 +28,7 @@ func TestContain(t *testing.T) {
|
||||
func contain(t *testing.T, test interface{}, value interface{}, expected bool) {
|
||||
res := Contain(test, value)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "Contain", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "Contain", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func TestChunk(t *testing.T) {
|
||||
func chunk(t *testing.T, test []interface{}, num int, expected [][]interface{}) {
|
||||
res := Chunk(test, num)
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "Chunk", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "Chunk", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func TestEvery(t *testing.T) {
|
||||
}
|
||||
res := Every(nums, isEven)
|
||||
if res != false {
|
||||
utils.LogFailedTestInfo(t, "Every", nums, false, res)
|
||||
internal.LogFailedTestInfo(t, "Every", nums, false, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func TestSome(t *testing.T) {
|
||||
}
|
||||
res := Some(nums, isEven)
|
||||
if res != true {
|
||||
utils.LogFailedTestInfo(t, "Some", nums, true, res)
|
||||
internal.LogFailedTestInfo(t, "Some", nums, true, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func TestFilter(t *testing.T) {
|
||||
e1 := []int{2, 4}
|
||||
r1 := Filter(nums, even)
|
||||
if !reflect.DeepEqual(r1, e1) {
|
||||
utils.LogFailedTestInfo(t, "Filter", nums, e1, r1)
|
||||
internal.LogFailedTestInfo(t, "Filter", nums, e1, r1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ func TestFilter(t *testing.T) {
|
||||
|
||||
r2 := Filter(students, filterFunc)
|
||||
if !reflect.DeepEqual(r2, e2) {
|
||||
utils.LogFailedTestInfo(t, "Filter", students, e2, r2)
|
||||
internal.LogFailedTestInfo(t, "Filter", students, e2, r2)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func TestFind(t *testing.T) {
|
||||
}
|
||||
res := Find(nums, even)
|
||||
if res != 2 {
|
||||
utils.LogFailedTestInfo(t, "Find", nums, 2, res)
|
||||
internal.LogFailedTestInfo(t, "Find", nums, 2, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func TestMap(t *testing.T) {
|
||||
e1 := []int{2, 4, 6, 8}
|
||||
r1 := Map(s1, multiplyTwo)
|
||||
if !reflect.DeepEqual(r1, e1) {
|
||||
utils.LogFailedTestInfo(t, "Map", s1, e1, r1)
|
||||
internal.LogFailedTestInfo(t, "Map", s1, e1, r1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func TestMap(t *testing.T) {
|
||||
}
|
||||
r2 := Map(students, mapFunc)
|
||||
if !reflect.DeepEqual(r2, e2) {
|
||||
utils.LogFailedTestInfo(t, "Filter", students, e2, r2)
|
||||
internal.LogFailedTestInfo(t, "Filter", students, e2, r2)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func TestReduce(t *testing.T) {
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := Reduce(cases[i], f, 0)
|
||||
if res != expected[i] {
|
||||
utils.LogFailedTestInfo(t, "Reduce", cases[i], expected[i], res)
|
||||
internal.LogFailedTestInfo(t, "Reduce", cases[i], expected[i], res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ func intSlice(t *testing.T, test interface{}, expected []int) {
|
||||
res := IntSlice(test)
|
||||
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "IntSlice", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IntSlice", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ func TestStringSlice(t *testing.T) {
|
||||
func stringSlice(t *testing.T, test interface{}, expected []string) {
|
||||
res := StringSlice(test)
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "StringSlice", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "StringSlice", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,7 @@ func TestInterfaceSlice(t *testing.T) {
|
||||
func interfaceSlice(t *testing.T, test interface{}, expected []interface{}) {
|
||||
res := InterfaceSlice(test)
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "InterfaceSlice", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "InterfaceSlice", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func deleteByIndex(t *testing.T, origin, test interface{}, start, end int, expec
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "DeleteByIndex", origin, expected, res)
|
||||
internal.LogFailedTestInfo(t, "DeleteByIndex", origin, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ func insertByIndex(t *testing.T, test interface{}, index int, value, expected in
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "InsertByIndex", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "InsertByIndex", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -385,7 +385,7 @@ func updateByIndex(t *testing.T, test interface{}, index int, value, expected in
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "UpdateByIndex", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "UpdateByIndex", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ func TestUnique(t *testing.T) {
|
||||
e1 := []int{1, 2, 3}
|
||||
r1 := Unique(t1)
|
||||
if !reflect.DeepEqual(r1, e1) {
|
||||
utils.LogFailedTestInfo(t, "Unique", t1, e1, r1)
|
||||
internal.LogFailedTestInfo(t, "Unique", t1, e1, r1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ func TestUnique(t *testing.T) {
|
||||
e2 := []string{"a", "b", "c"}
|
||||
r2 := Unique(t2)
|
||||
if !reflect.DeepEqual(r2, e2) {
|
||||
utils.LogFailedTestInfo(t, "Unique", t2, e2, r2)
|
||||
internal.LogFailedTestInfo(t, "Unique", t2, e2, r2)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -416,14 +416,14 @@ func TestUnion(t *testing.T) {
|
||||
expected1 := []int{1, 3, 4, 6, 2, 5, 0, 7}
|
||||
res1 := Union(s1, s2, s3)
|
||||
if !reflect.DeepEqual(res1, expected1) {
|
||||
utils.LogFailedTestInfo(t, "Union", s1, expected1, res1)
|
||||
internal.LogFailedTestInfo(t, "Union", s1, expected1, res1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
expected2 := []int{1, 3, 4, 6}
|
||||
res2 := Union(s1)
|
||||
if !reflect.DeepEqual(res2, expected2) {
|
||||
utils.LogFailedTestInfo(t, "Union", s1, expected2, res2)
|
||||
internal.LogFailedTestInfo(t, "Union", s1, expected2, res2)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -448,7 +448,7 @@ func TestIntersection(t *testing.T) {
|
||||
}
|
||||
for i := 0; i < len(res); i++ {
|
||||
if !reflect.DeepEqual(res[i], expected[i]) {
|
||||
utils.LogFailedTestInfo(t, "Intersection", "Intersection", expected[i], res[i])
|
||||
internal.LogFailedTestInfo(t, "Intersection", "Intersection", expected[i], res[i])
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -460,7 +460,7 @@ func TestReverseSlice(t *testing.T) {
|
||||
e1 := []int{5, 4, 3, 2, 1}
|
||||
ReverseSlice(s1)
|
||||
if !reflect.DeepEqual(s1, e1) {
|
||||
utils.LogFailedTestInfo(t, "ReverseSlice", s1, e1, s1)
|
||||
internal.LogFailedTestInfo(t, "ReverseSlice", s1, e1, s1)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ func TestReverseSlice(t *testing.T) {
|
||||
e2 := []string{"e", "d", "c", "b", "a"}
|
||||
ReverseSlice(s2)
|
||||
if !reflect.DeepEqual(s2, e2) {
|
||||
utils.LogFailedTestInfo(t, "ReverseSlice", s2, e2, s2)
|
||||
internal.LogFailedTestInfo(t, "ReverseSlice", s2, e2, s2)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -479,7 +479,7 @@ func TestDifference(t *testing.T) {
|
||||
e1 := []int{1, 2, 3}
|
||||
r1 := Difference(s1, s2)
|
||||
if !reflect.DeepEqual(r1, e1) {
|
||||
utils.LogFailedTestInfo(t, "Difference", s1, e1, r1)
|
||||
internal.LogFailedTestInfo(t, "Difference", s1, e1, r1)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -509,7 +509,7 @@ func TestSortByField(t *testing.T) {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(students, sortByAge) {
|
||||
utils.LogFailedTestInfo(t, "SortByField", students, sortByAge, students)
|
||||
internal.LogFailedTestInfo(t, "SortByField", students, sortByAge, students)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ func TestWithout(t *testing.T) {
|
||||
res := Without(s, 1, 2)
|
||||
|
||||
if !reflect.DeepEqual(res, expected) {
|
||||
utils.LogFailedTestInfo(t, "Without", s, expected, res)
|
||||
internal.LogFailedTestInfo(t, "Without", s, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package strutil
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestCamelCase(t *testing.T) {
|
||||
@@ -16,7 +16,7 @@ func TestCamelCase(t *testing.T) {
|
||||
func camelCase(t *testing.T, test string, expected string) {
|
||||
res := CamelCase(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "CamelCase", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "CamelCase", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ func TestCapitalize(t *testing.T) {
|
||||
func capitalize(t *testing.T, test string, expected string) {
|
||||
res := Capitalize(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "Capitalize", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "Capitalize", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func TestKebabCase(t *testing.T) {
|
||||
func kebabCase(t *testing.T, test string, expected string) {
|
||||
res := KebabCase(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "KebabCase", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "KebabCase", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestSnakeCase(t *testing.T) {
|
||||
func snakeCase(t *testing.T, test string, expected string) {
|
||||
res := SnakeCase(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "SnakeCase", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "SnakeCase", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func TestLowerFirst(t *testing.T) {
|
||||
func lowerFirst(t *testing.T, test string, expected string) {
|
||||
res := LowerFirst(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "LowerFirst", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "LowerFirst", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func TestPadEnd(t *testing.T) {
|
||||
func padEnd(t *testing.T, source string, size int, fillString string, expected string) {
|
||||
res := PadEnd(source, size, fillString)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "PadEnd", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "PadEnd", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func TestPadStart(t *testing.T) {
|
||||
func padStart(t *testing.T, source string, size int, fillString string, expected string) {
|
||||
res := PadStart(source, size, fillString)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "PadEnd", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "PadEnd", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ func TestBefore(t *testing.T) {
|
||||
func before(t *testing.T, source, char, expected string) {
|
||||
res := Before(source, char)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "Before", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "Before", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func TestBeforeLast(t *testing.T) {
|
||||
func beforeLast(t *testing.T, source, char, expected string) {
|
||||
res := BeforeLast(source, char)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "BeforeLast", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "BeforeLast", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func TestAfter(t *testing.T) {
|
||||
func after(t *testing.T, source, char, expected string) {
|
||||
res := After(source, char)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "After", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "After", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ func TestAfterLast(t *testing.T) {
|
||||
func afterLast(t *testing.T, source, char, expected string) {
|
||||
res := AfterLast(source, char)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "AfterLast", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "AfterLast", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func TestIsString(t *testing.T) {
|
||||
func isString(t *testing.T, test interface{}, expected bool) {
|
||||
res := IsString(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsString", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsString", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ func TestReverseStr(t *testing.T) {
|
||||
func reverseStr(t *testing.T, test string, expected string) {
|
||||
res := ReverseStr(test)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "ReverseStr", test, expected, res)
|
||||
internal.LogFailedTestInfo(t, "ReverseStr", test, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package validator
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/utils"
|
||||
"github.com/duke-git/lancet/internal"
|
||||
)
|
||||
|
||||
func TestIsNumberStr(t *testing.T) {
|
||||
@@ -17,7 +17,7 @@ func TestIsNumberStr(t *testing.T) {
|
||||
func isNumberStr(t *testing.T, source string, expected bool) {
|
||||
res := IsNumberStr(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsNumberStr", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsNumberStr", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func TestIsFloatStr(t *testing.T) {
|
||||
func isFloatStr(t *testing.T, source string, expected bool) {
|
||||
res := IsFloatStr(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsFloatStr", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsFloatStr", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func TestIsIntStr(t *testing.T) {
|
||||
func isIntStr(t *testing.T, source string, expected bool) {
|
||||
res := IsIntStr(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsIntStr", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsIntStr", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func TestIsIp(t *testing.T) {
|
||||
func isIp(t *testing.T, source string, expected bool) {
|
||||
res := IsIp(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsIp", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsIp", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func TestIsIpV4(t *testing.T) {
|
||||
func isIpV4(t *testing.T, source string, expected bool) {
|
||||
res := IsIpV4(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsIpV4", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsIpV4", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func TestIsIpV6(t *testing.T) {
|
||||
func isIpV6(t *testing.T, source string, expected bool) {
|
||||
res := IsIpV6(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsIpV6", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsIpV6", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestIsDns(t *testing.T) {
|
||||
func isDns(t *testing.T, source string, expected bool) {
|
||||
res := IsDns(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsDns", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsDns", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func TestIsEmail(t *testing.T) {
|
||||
func isEmail(t *testing.T, source string, expected bool) {
|
||||
res := IsEmail(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsEmail", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsEmail", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func TestContainChinese(t *testing.T) {
|
||||
func containChinese(t *testing.T, source string, expected bool) {
|
||||
res := ContainChinese(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsContainChineseChar", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsContainChineseChar", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func TestIsChineseMobile(t *testing.T) {
|
||||
func isChineseMobile(t *testing.T, source string, expected bool) {
|
||||
res := IsChineseMobile(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsChineseMobile", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsChineseMobile", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func TestIsChinesePhone(t *testing.T) {
|
||||
func isChinesePhone(t *testing.T, source string, expected bool) {
|
||||
res := IsChinesePhone(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsChinesePhone", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsChinesePhone", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ func TestIsChineseIdNum(t *testing.T) {
|
||||
func isChineseIdNum(t *testing.T, source string, expected bool) {
|
||||
res := IsChineseIdNum(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsChineseIdNum", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsChineseIdNum", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func TestIsCreditCard(t *testing.T) {
|
||||
func isCreditCard(t *testing.T, source string, expected bool) {
|
||||
res := IsCreditCard(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsCreditCard", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsCreditCard", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ func TestIsBase64(t *testing.T) {
|
||||
func isBase64(t *testing.T, source string, expected bool) {
|
||||
res := IsBase64(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsBase64", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsBase64", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ func TestIsEmptyString(t *testing.T) {
|
||||
func isEmptyString(t *testing.T, source string, expected bool) {
|
||||
res := IsEmptyString(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsEmptyString", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsEmptyString", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func TestIsAlpha(t *testing.T) {
|
||||
func isAlpha(t *testing.T, source string, expected bool) {
|
||||
res := IsAlpha(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsAlpha", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsAlpha", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func TestIsRegexMatch(t *testing.T) {
|
||||
func isRegexMatch(t *testing.T, source, regex string, expected bool) {
|
||||
res := IsRegexMatch(source, regex)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsRegexMatch", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsRegexMatch", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -261,7 +261,7 @@ func TestIsStrongPassword(t *testing.T) {
|
||||
func isStrongPassword(t *testing.T, source string, length int, expected bool) {
|
||||
res := IsStrongPassword(source, length)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsStrongPassword", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsStrongPassword", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ func TestIsWeakPassword(t *testing.T) {
|
||||
func isWeakPassword(t *testing.T, source string, expected bool) {
|
||||
res := IsWeakPassword(source)
|
||||
if res != expected {
|
||||
utils.LogFailedTestInfo(t, "IsWeakPassword", source, expected, res)
|
||||
internal.LogFailedTestInfo(t, "IsWeakPassword", source, expected, res)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user