mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
enh(DateTimeParser): option to cleanup input string before parsing (#569).
This commit is contained in:
@@ -751,6 +751,28 @@ void DateTimeParserTest::testGuess()
|
||||
assertTrue (tzd == 0);
|
||||
}
|
||||
|
||||
void DateTimeParserTest::testCleanup()
|
||||
{
|
||||
int tzd;
|
||||
|
||||
DateTime dt = DateTimeParser::parse("2005-01-08T12:30:00Z", tzd);
|
||||
DateTime dt2 = DateTimeParser::parse(" 2005-01-08T12:30:00Z ", tzd);
|
||||
|
||||
assertTrue (dt == dt2);
|
||||
|
||||
assertTrue(DateTimeParser::tryParse(" 2005-01-08T12:30:00Z ", dt, tzd));
|
||||
|
||||
dt = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.1Z", tzd);
|
||||
dt2 = DateTimeParser::parse(DateTimeFormat::ISO8601_FRAC_FORMAT, "2005-01-08T12:30:00.1Z ", tzd);
|
||||
|
||||
assertTrue (dt == dt2);
|
||||
|
||||
assertTrue(DateTimeParser::tryParse(DateTimeFormat::ISO8601_FRAC_FORMAT, " 2005-01-08T12:30:00Z ", dt, tzd));
|
||||
|
||||
assertFalse(DateTimeParser::tryParse(DateTimeFormat::ISO8601_FRAC_FORMAT, " ", dt, tzd));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DateTimeParserTest::testParseMonth()
|
||||
{
|
||||
@@ -790,7 +812,7 @@ void DateTimeParserTest::testParseMonth()
|
||||
month = DateTimeParser::parseMonth(it, str.end());
|
||||
fail("Not a valid month name - must throw");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
catch (const SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -834,7 +856,7 @@ void DateTimeParserTest::testParseDayOfWeek()
|
||||
dow = DateTimeParser::parseDayOfWeek(it, str.end());
|
||||
fail("Not a valid weekday name - must throw");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
catch (const SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -877,6 +899,7 @@ CppUnit::Test* DateTimeParserTest::suite()
|
||||
CppUnit_addTest(pSuite, DateTimeParserTest, testSORTABLE);
|
||||
CppUnit_addTest(pSuite, DateTimeParserTest, testCustom);
|
||||
CppUnit_addTest(pSuite, DateTimeParserTest, testGuess);
|
||||
CppUnit_addTest(pSuite, DateTimeParserTest, testCleanup);
|
||||
CppUnit_addTest(pSuite, DateTimeParserTest, testParseMonth);
|
||||
CppUnit_addTest(pSuite, DateTimeParserTest, testParseDayOfWeek);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user