summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2020-10-13 10:59:44 +0200
committerAndreas Buhr <andreas.buhr@qt.io>2020-10-22 13:54:45 +0200
commit373fdc9126cd7f5efccdc44f23ab0427bba31a0e (patch)
treedaf7a7c61ce2130c8e153481be966ec19db8bf11 /tests/auto
parent0e5bbf3507666954fefa5e3c4a2eea531ce71259 (diff)
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>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index d5fc0502d2..82db37638e 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -2508,8 +2508,18 @@ void tst_QDateTime::fromStringDateFormat_data()
<< Qt::RFC2822Date << QDateTime();
QTest::newRow("RFC 2822 with day date only") << QString::fromLatin1("Fri, 01 Nov 2002")
<< 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();
+ 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
QTest::newRow("RFC 2822 invalid month name") << QString::fromLatin1("13 Fev 1987 13:24:51 +0100")
<< Qt::RFC2822Date << QDateTime();