diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-18 16:31:13 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-10-19 17:44:05 +0200 |
commit | 229c9736bb7738ae181f2db3fa71623b5b3582fb (patch) | |
tree | b0c8373c2488bfdb469320d32ef72230ea2306b0 /tests | |
parent | 9d2a107da2e5af77dece660b5d2b0958e79dc284 (diff) |
Check time-text is long enough while checking for its colons
Added some tests that trigger an assert without this check.
(Drive-by: renamed one QTime test to match its QDate(Time)? counterparts.)
Change-Id: I3d6767605fdcca13a9b4d43a32904f584eb57cf9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/time/qdate/tst_qdate.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/time/qtime/tst_qtime.cpp | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index c133ed3c76..c83aa28c20 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -1149,6 +1149,8 @@ void tst_QDate::fromStringDateFormat_data() << Qt::RFC2822Date << QDate(2002, 11, 1); QTest::newRow("RFC 2822 with day date only") << QString::fromLatin1("Fri, 01 Nov 2002") << Qt::RFC2822Date << QDate(2002, 11, 1); + QTest::newRow("RFC 2822 malformed time") + << QString::fromLatin1("01 Nov 2002 0:") << Qt::RFC2822Date << QDate(); // Test invalid month, day, year QTest::newRow("RFC 2822 invalid month name") << QString::fromLatin1("13 Fev 1987 13:24:51 +0100") << Qt::RFC2822Date << QDate(); diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 13176e5afc..d5fc0502d2 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -2508,6 +2508,8 @@ 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") + << QString::fromLatin1("01 Nov 2002 0:") << 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(); diff --git a/tests/auto/corelib/time/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp index ce8a24515b..289a46e176 100644 --- a/tests/auto/corelib/time/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp @@ -651,6 +651,8 @@ void tst_QTime::fromStringDateFormat_data() << Qt::RFC2822Date << invalidTime(); QTest::newRow("RFC 2822 with day date only") << QString::fromLatin1("Fri, 01 Nov 2002") << Qt::RFC2822Date << invalidTime(); + QTest::newRow("RFC 2822 malformed time") + << QString::fromLatin1("01 Nov 2002 0:") << Qt::RFC2822Date << QTime(); // Test invalid month, day, year are ignored: QTest::newRow("RFC 2822 invalid month name") << QString::fromLatin1("13 Fev 1987 13:24:51 +0100") << Qt::RFC2822Date << QTime(13, 24, 51); @@ -678,7 +680,7 @@ void tst_QTime::fromStringDateFormat_data() << Qt::RFC2822Date << invalidTime(); // The common date text used by the "invalid character" tests, just to be // sure *it's* not what's invalid: - QTest::newRow("RFC 2822 invalid character at end") + QTest::newRow("RFC 2822 (not invalid)") << QString::fromLatin1("01 Jan 2012 08:00:00 +0100") << Qt::RFC2822Date << QTime(8, 0, 0); |