Add unit test for malformed RFC2822 dates
RFC2822 requires times to be in the format 'HH:mm' or 'HH:mm:ss'. We did not have unit tests to check that malformed RFC2822 dates are rejected. This patch adds such unit tests for truncated hours/minutes/seconds. Change-Id: Id5b9390112e633e617722439ad59439e6aeba841 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
0e5bbf3507
commit
373fdc9126
@ -2508,8 +2508,18 @@ void tst_QDateTime::fromStringDateFormat_data()
|
|||||||
<< Qt::RFC2822Date << QDateTime();
|
<< Qt::RFC2822Date << QDateTime();
|
||||||
QTest::newRow("RFC 2822 with day date only") << QString::fromLatin1("Fri, 01 Nov 2002")
|
QTest::newRow("RFC 2822 with day date only") << QString::fromLatin1("Fri, 01 Nov 2002")
|
||||||
<< Qt::RFC2822Date << QDateTime();
|
<< Qt::RFC2822Date << QDateTime();
|
||||||
QTest::newRow("RFC 2822 malformed time")
|
|
||||||
|
QTest::newRow("RFC 2822 malformed time (truncated)")
|
||||||
<< QString::fromLatin1("01 Nov 2002 0:") << Qt::RFC2822Date << QDateTime();
|
<< QString::fromLatin1("01 Nov 2002 0:") << Qt::RFC2822Date << QDateTime();
|
||||||
|
QTest::newRow("RFC 2822 malformed time (hour)")
|
||||||
|
<< QString::fromLatin1("01 Nov 2002 7:35:21") << Qt::RFC2822Date << QDateTime();
|
||||||
|
QTest::newRow("RFC 2822 malformed time (minute)")
|
||||||
|
<< QString::fromLatin1("01 Nov 2002 07:5:21") << Qt::RFC2822Date << QDateTime();
|
||||||
|
QTest::newRow("RFC 2822 malformed time (second)")
|
||||||
|
<< QString::fromLatin1("01 Nov 2002 07:35:1") << Qt::RFC2822Date << QDateTime();
|
||||||
|
QTest::newRow("RFC 2822 malformed time (fraction-second)")
|
||||||
|
<< QString::fromLatin1("01 Nov 2002 07:35:15.200") << Qt::RFC2822Date << QDateTime();
|
||||||
|
|
||||||
// Test invalid month, day, year
|
// Test invalid month, day, year
|
||||||
QTest::newRow("RFC 2822 invalid month name") << QString::fromLatin1("13 Fev 1987 13:24:51 +0100")
|
QTest::newRow("RFC 2822 invalid month name") << QString::fromLatin1("13 Fev 1987 13:24:51 +0100")
|
||||||
<< Qt::RFC2822Date << QDateTime();
|
<< Qt::RFC2822Date << QDateTime();
|
||||||
|
Loading…
Reference in New Issue
Block a user