mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-16 12:00:55 +08:00
unit test
This commit is contained in:
@@ -23,20 +23,22 @@ func TestIsTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsDate(t *testing.T) {
|
||||
if !IsDate("2023-03-11") {
|
||||
t.Error("Expected true, got false")
|
||||
testCases := []struct {
|
||||
input string
|
||||
expected bool
|
||||
}{
|
||||
{"2021-01-01", true},
|
||||
{"2021/01/01", false},
|
||||
{"2021-13-01", false},
|
||||
{"2021-02-29", false},
|
||||
{"2020-02-29", true},
|
||||
}
|
||||
if IsDate("2023-02-29") {
|
||||
t.Error("Expected false, got true")
|
||||
}
|
||||
if IsDate("2023-04-31") {
|
||||
t.Error("Expected false, got true")
|
||||
}
|
||||
if IsDate("2023-13-01") {
|
||||
t.Error("Expected false, got true")
|
||||
}
|
||||
if IsDate("2023-03-11 12:34:56") {
|
||||
t.Error("Expected false, got true")
|
||||
|
||||
for _, testCase := range testCases {
|
||||
result := IsDate(testCase.input)
|
||||
if result != testCase.expected {
|
||||
t.Errorf("IsDate(%v) = %v, expected %v", testCase.input, result, testCase.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user