mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
time: sanity check parsed date/times
This commit is contained in:
parent
3c7c11e55b
commit
23e679475c
2 changed files with 87 additions and 26 deletions
|
@ -136,3 +136,26 @@ fn test_parse_iso8601_date_only() {
|
|||
assert t.second == 0
|
||||
assert t.microsecond == 0
|
||||
}
|
||||
|
||||
fn check_invalid_date(s string) {
|
||||
if date := time.parse(s) {
|
||||
eprintln('invalid date: "$s" => "$date"')
|
||||
assert false
|
||||
}
|
||||
assert true
|
||||
}
|
||||
|
||||
fn test_invalid_dates_should_error_during_parse() {
|
||||
check_invalid_date('-99999-12-20 00:00:00')
|
||||
check_invalid_date('99999-12-20 00:00:00')
|
||||
//
|
||||
check_invalid_date('2008-00-20 00:00:00')
|
||||
check_invalid_date('2008-25-20 00:00:00')
|
||||
//
|
||||
check_invalid_date('2008-12-00 00:00:00')
|
||||
check_invalid_date('2008-12-32 00:00:00')
|
||||
//
|
||||
check_invalid_date('2008-12-01 30:00:00')
|
||||
check_invalid_date('2008-12-01 00:60:00')
|
||||
check_invalid_date('2008-12-01 00:01:60')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue