DateTimeParser Validation and Performance Improvements (#4593)

This commit is contained in:
Andrew Auclair
2024-06-29 16:13:51 -04:00
committed by GitHub
parent 02b59b4d25
commit a82b766628
4 changed files with 210 additions and 83 deletions

View File

@@ -177,6 +177,7 @@ void DateTimeParserTest::testISO8601Frac()
assertTrue (dt.microsecond() == 0);
assertTrue (tzd == 0);
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.1J", tzd);
testBad(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.Z", tzd);
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.123+01:00", tzd);
assertTrue (dt.year() == 2005);
@@ -616,6 +617,15 @@ void DateTimeParserTest::testCustom()
catch (SyntaxException&)
{
}
// bad year (not a number)
testBad("%y", "YY", tzd);
// bad year (number too big)
testBad("%r", "123456789101112131415", tzd);
// check that an invalid millisecond is detected with a custom format
testBad("T%H:%M:%s %z", "T12:30:00.Z", tzd);
}