mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
update: update validator test function
This commit is contained in:
2
.github/workflows/codecov.yml
vendored
2
.github/workflows/codecov.yml
vendored
@@ -17,6 +17,6 @@ jobs:
|
||||
with:
|
||||
go-version: "1.16"
|
||||
- name: Run coverage
|
||||
run: go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||
run: go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic
|
||||
- name: Upload coverage to Codecov
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
.idea/*
|
||||
.vscode/*
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
cryptor/*.txt
|
||||
fileutil/*.txt
|
||||
cryptor/*.pem
|
||||
@@ -87,11 +87,11 @@ func TestCopyFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListFileNames(t *testing.T) {
|
||||
filesInCurrentPath, err := ListFileNames("./")
|
||||
filesInCurrentPath, err := ListFileNames("../datetime/")
|
||||
if err != nil {
|
||||
t.FailNow()
|
||||
}
|
||||
expected := []string{"file.go", "file_test.go"}
|
||||
expected := []string{"datetime.go", "datetime_test.go"}
|
||||
if !reflect.DeepEqual(filesInCurrentPath, expected) {
|
||||
utils.LogFailedTestInfo(t, "ToChar", "./", expected, filesInCurrentPath)
|
||||
t.FailNow()
|
||||
|
||||
@@ -26,11 +26,7 @@ func IsNumberStr(s string) bool {
|
||||
// IsFloatStr check if the string can convert to a float.
|
||||
func IsFloatStr(s string) bool {
|
||||
_, e := strconv.ParseFloat(s, 64)
|
||||
|
||||
if e != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return e == nil
|
||||
}
|
||||
|
||||
// IsIntStr check if the string can convert to a integer.
|
||||
@@ -42,10 +38,7 @@ func IsIntStr(s string) bool {
|
||||
// IsIp check if the string is a ip address.
|
||||
func IsIp(ipstr string) bool {
|
||||
ip := net.ParseIP(ipstr)
|
||||
if ip == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return ip != nil
|
||||
}
|
||||
|
||||
// IsIpV4 check if the string is a ipv4 address.
|
||||
|
||||
@@ -190,7 +190,7 @@ func isCreditCard(t *testing.T, source string, expected bool) {
|
||||
}
|
||||
|
||||
func TestIsBase64(t *testing.T) {
|
||||
isBase64(t, "aGVsbG8", true)
|
||||
isBase64(t, "aGVsbG8=", true)
|
||||
isBase64(t, "123456", false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user