Skip to content

Commit

Permalink
timeFormatCheck add new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
martianzhang committed May 18, 2021
1 parent cb63ad7 commit dd44876
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion advisor/heuristic.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func timeFormatCheck(t string) bool {
// 不允许为空,但允许时间前后有空格
t = strings.TrimSpace(t)
// 仅允许 数字、减号、冒号、空格
allowChars := regexp.MustCompile(`^[\-0-9: ]+$`)
allowChars := regexp.MustCompile(`^[\-0-9:. ]+$`)
return allowChars.MatchString(t)
}

Expand Down
3 changes: 3 additions & 0 deletions advisor/heuristic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func TestRuleEqualLike(t *testing.T) {
func TestTimeFormatError(t *testing.T) {
rightTimes := []string{
`2020-01-01`,
`2020-01-01 23:59:59`,
`2020-01-01 23:59:59.0`, // 0ms
`2020-01-01 23:59:59.123`, // 123ms
}
for _, rt := range rightTimes {
if !timeFormatCheck(rt) {
Expand Down

0 comments on commit dd44876

Please sign in to comment.