diff options
author | Benjamin C Meyer <benjamin.meyer@torchmobile.com> | 2009-03-26 14:53:09 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@trolltech.com> | 2009-03-30 15:44:23 (GMT) |
commit | ece28c5e497c5a7ce1f7671094c5ff3e58d176c5 (patch) | |
tree | f5d831e90baaaf4caa592fc7e78d94a43cd40765 /tests | |
parent | 9cc1b5573affdfcf1862369afe387c8fdf8474e6 (diff) | |
download | Qt-ece28c5e497c5a7ce1f7671094c5ff3e58d176c5.zip Qt-ece28c5e497c5a7ce1f7671094c5ff3e58d176c5.tar.gz Qt-ece28c5e497c5a7ce1f7671094c5ff3e58d176c5.tar.bz2 |
Autotest: more date-time parsing tests for QNetworkCookie
Signoff-by: Thiago Macieira <thiago.macieira@nokia.com>
Signed-off-by: Peter Hartmann <peter.hartmann@trolltech.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 4da17d9..2187b61 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -286,8 +286,263 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("expiration3") << "a=b; expires=Wednesday, 09-Nov-1999 23:12:40 GMT " << cookie; QTest::newRow("expiration-utc") << "a=b;expires=Wednesday, 09-Nov-1999 23:12:40 UTC" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("time-0") << "a=b;expires=14 Apr 89 03:20" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 0), Qt::UTC)); + QTest::newRow("time-1") << "a=b;expires=14 Apr 89 03:20:12" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-2") << "a=b;expires=14 Apr 89 03:20:12.88" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-3") << "a=b;expires=14 Apr 89 03:20:12.88am" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-4") << "a=b;expires=14 Apr 89 03:20:12.88pm" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-5") << "a=b;expires=14 Apr 89 03:20:12.88 Am" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-6") << "a=b;expires=14 Apr 89 03:20:12.88 PM" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(15, 20, 12, 88), Qt::UTC)); + QTest::newRow("time-7") << "a=b;expires=14 Apr 89 3:20:12.88 PM" << cookie; + + // normal months + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-1") << "a=b;expires=Jan 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 2, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-2") << "a=b;expires=Feb 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-3") << "a=b;expires=mar 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-4") << "a=b;expires=Apr 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 5, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-5") << "a=b;expires=May 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 6, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-6") << "a=b;expires=Jun 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 7, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-7") << "a=b;expires=Jul 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 8, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-8") << "a=b;expires=Aug 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 9, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-9") << "a=b;expires=Sep 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 10, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-10") << "a=b;expires=Oct 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 11, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-11") << "a=b;expires=Nov 1 89 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-12") << "a=b;expires=Dec 1 89 1:1" << cookie; + + // extra months + cookie.setExpirationDate(QDateTime(QDate(1989, 12, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-13") << "a=b;expires=December 1 89 1:1" << cookie; + QTest::newRow("months-14") << "a=b;expires=1 89 1:1 Dec" << cookie; + //cookie.setExpirationDate(QDateTime()); + //QTest::newRow("months-15") << "a=b;expires=1 89 1:1 De" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-16") << "a=b;expires=2024 29 Feb 1:1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2024, 2, 29), QTime(1, 1), Qt::UTC)); + QTest::newRow("months-17") << "a=b;expires=Fri, 29-Feb-2024 01:01:00 GMT" << cookie; + QTest::newRow("months-18") << "a=b;expires=2024 29 Feb 1:1 GMT" << cookie; + + // normal offsets + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-0") << "a=b;expires=Jan 1 89 8:0 PST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-1") << "a=b;expires=Jan 1 89 8:0 PDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-2") << "a=b;expires=Jan 1 89 7:0 MST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-3") << "a=b;expires=Jan 1 89 7:0 MDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-4") << "a=b;expires=Jan 1 89 6:0 CST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-5") << "a=b;expires=Jan 1 89 6:0 CDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-6") << "a=b;expires=Jan 1 89 5:0 EST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-7") << "a=b;expires=Jan 1 89 5:0 EDT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-8") << "a=b;expires=Jan 1 89 4:0 AST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-9") << "a=b;expires=Jan 1 89 3:0 NST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-10") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-11") << "a=b;expires=Jan 1 89 0:0 BST" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-12") << "a=b;expires=Jan 1 89 23:0 MET" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-13") << "a=b;expires=Jan 1 89 22:0 EET" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST" << cookie; + + // extra offsets + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-14") << "a=b;expires=Jan 1 89 15:0 JST+1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-15") << "a=b;expires=Jan 1 89 0:0 GMT+1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-15b") << "a=b;expires=Jan 1 89 1:0 GMT-1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-16") << "a=b;expires=Jan 1 89 0:0 GMT+01" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 5), Qt::UTC)); + QTest::newRow("zoneoffset-17") << "a=b;expires=Jan 1 89 0:0 GMT+0105" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-18") << "a=b;expires=Jan 1 89 0:0 GMT+015" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-19") << "a=b;expires=Jan 1 89 0:0 GM" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-19b") << "a=b;expires=Jan 1 89 0:0 GMT" << cookie; + + // offsets from gmt + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-20") << "a=b;expires=Jan 1 89 0:0 +1" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 0), Qt::UTC)); + QTest::newRow("zoneoffset-21") << "a=b;expires=Jan 1 89 0:0 +01" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(1, 1), Qt::UTC)); + QTest::newRow("zoneoffset-22") << "a=b;expires=Jan 1 89 0:0 +0101" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("zoneoffset-23") << "a=b;expires=Jan 1 89 1:0 -1" << cookie; + + // Y2k + cookie.setExpirationDate(QDateTime(QDate(2000, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-0") << "a=b;expires=Jan 1 00 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-1") << "a=b;expires=Jan 1 70 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1971, 1, 1), QTime(0, 0), Qt::UTC)); + QTest::newRow("year-2") << "a=b;expires=Jan 1 71 0:0" << cookie; + + // Day, month, year + cookie.setExpirationDate(QDateTime(QDate(2013, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("date-0") << "a=b;expires=Jan 2 13 0:0" << cookie; + QTest::newRow("date-1") << "a=b;expires=1-2-13 0:0" << cookie; + QTest::newRow("date-2") << "a=b;expires=1/2/13 0:0" << cookie; + QTest::newRow("date-3") << "a=b;expires=Jan 2 13 0:0" << cookie; + QTest::newRow("date-4") << "a=b;expires=Jan 2, 13 0:0" << cookie; + QTest::newRow("date-5") << "a=b;expires=1-2-13 0:0" << cookie; + QTest::newRow("date-6") << "a=b;expires=1/2/13 0:0" << cookie; + + // Known Year, determine month and day + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownyear-0") << "a=b;expires=13/1/95 0:0" << cookie; + QTest::newRow("knownyear-1") << "a=b;expires=95/13/1 0:0" << cookie; + QTest::newRow("knownyear-2") << "a=b;expires=1995/1/13 0:0" << cookie; + QTest::newRow("knownyear-3") << "a=b;expires=1995/13/1 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownyear-4") << "a=b;expires=1/2/95 0:0" << cookie; + QTest::newRow("knownyear-5") << "a=b;expires=95/1/2 0:0" << cookie; + + // Known Year, Known day, determining month + cookie.setExpirationDate(QDateTime(QDate(1995, 1, 13), QTime(0, 0), Qt::UTC)); + QTest::newRow("knownYD-0") << "a=b;expires=13/1/95 0:0" << cookie; + QTest::newRow("knownYD-1") << "a=b;expires=1/13/95 0:0" << cookie; + QTest::newRow("knownYD-2") << "a=b;expires=95/13/1 0:0" << cookie; + QTest::newRow("knownYD-3") << "a=b;expires=95/1/13 0:0" << cookie; + + // Month comes before Year + cookie.setExpirationDate(QDateTime(QDate(2021, 03, 26), QTime(0, 0), Qt::UTC)); + QTest::newRow("month-0") << "a=b;expires=26/03/21 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2015, 12, 30), QTime(16, 25, 0, 0), Qt::UTC)); + QTest::newRow("month-1") << "a=b;expires=wed 16:25pm December 2015 30" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 11), QTime(16, 25, 0, 0), Qt::UTC)); + QTest::newRow("month-2") << "a=b;expires=16:25 11 31 11" << cookie; + + // The very ambiguous cases + // Matching Firefox's behavior of guessing month, day, year in those cases + cookie.setExpirationDate(QDateTime(QDate(2013, 10, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-0") << "a=b;expires=10/2/13 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2013, 2, 10), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-1") << "a=b;expires=2/10/13 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2010, 2, 3), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-2") << "a=b;expires=2/3/10 0:0" << cookie; + + // FYI If you try these in Firefox it wont set a cookie for the following two string + // because 03 is turned into the year at which point it is expired + cookie.setExpirationDate(QDateTime(QDate(2003, 2, 10), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-3") << "a=b;expires=2/10/3 0:0" << cookie; + cookie.setExpirationDate(QDateTime(QDate(2003, 10, 2), QTime(0, 0), Qt::UTC)); + QTest::newRow("ambiguousd-4") << "a=b;expires=10/2/3 0:0" << cookie; + + // These are the cookies that firefox's source says it can parse + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("firefox-0") << "a=b;expires=14 Apr 89 03:20" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 4, 14), QTime(3, 20, 0, 0), Qt::UTC)); + QTest::newRow("firefox-1") << "a=b;expires=14 Apr 89 03:20 GMT" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 33, 0), Qt::UTC)); + QTest::newRow("firefox-2") << "a=b;expires=Fri, 17 Mar 89 4:01:33" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 3, 17), QTime(4, 1, 0, 0), Qt::UTC)); + QTest::newRow("firefox-3") << "a=b;expires=Fri, 17 Mar 89 4:01 GMT" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(16-8, 12, 0, 0), Qt::UTC)); + QTest::newRow("firefox-4") << "a=b;expires=Mon Jan 16 16:12 PDT 1989" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1989, 1, 16), QTime(17, 42, 0, 0), Qt::UTC)); + QTest::newRow("firefox-5") << "a=b;expires=Mon Jan 16 16:12 +0130 1989" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1992, 5, 6), QTime(16-9, 41, 0, 0), Qt::UTC)); + QTest::newRow("firefox-6") << "a=b;expires=6 May 1992 16:41-JST (Wednesday)" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(10, 59, 12, 82), Qt::UTC)); + QTest::newRow("firefox-7") << "a=b;expires=22-AUG-1993 10:59:12.82" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(22, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-8") << "a=b;expires=22-AUG-1993 10:59pm" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-9") << "a=b;expires=22-AUG-1993 12:59am" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1993, 8, 22), QTime(12, 59, 0, 0), Qt::UTC)); + QTest::newRow("firefox-10") << "a=b;expires=22-AUG-1993 12:59 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 8, 4), QTime(15, 54, 0, 0), Qt::UTC)); + QTest::newRow("firefox-11") << "a=b;expires=Friday, August 04, 1995 3:54 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 21), QTime(16, 24, 34, 0), Qt::UTC)); + QTest::newRow("firefox-12") << "a=b;expires=06/21/95 04:24:34 PM" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 20), QTime(21, 7, 0, 0), Qt::UTC)); + QTest::newRow("firefox-13") << "a=b;expires=20/06/95 21:07" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(1995, 6, 8), QTime(19-5, 32, 48, 0), Qt::UTC)); + QTest::newRow("firefox-14") << "a=b;expires=95-06-08 19:32:48 EDT" << cookie; + + // Edge cases caught by fuzzing + // These are about the default cause creates dates that don't exits + cookie.setExpirationDate(QDateTime(QDate(2030, 2, 25), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-0") << "a=b; expires=30 -000002 1:1 25;" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 20), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-1") << "a=b; expires=31 11 20 1:1;" << cookie; + + // April only has 30 days + cookie.setExpirationDate(QDateTime(QDate(2031, 4, 30), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-2") << "a=b; expires=31 30 4 1:1" << cookie; + + // 9 must be the month so 31 can't be the day + cookie.setExpirationDate(QDateTime(QDate(2031, 9, 21), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-3") << "a=b; expires=31 21 9 1:1" << cookie; + + // Year is known, then fallback to defaults of filling in month and day + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 1), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-4") << "a=b; expires=31 11 01 1:1" << cookie; + + // 2 must be the month so 30 can't be the day + cookie.setExpirationDate(QDateTime(QDate(2030, 2, 20), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-5") << "a=b; expires=30 02 20 1:1" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2021, 12, 22), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-6") << "a=b; expires=2021 12 22 1:1" << cookie; + + cookie.setExpirationDate(QDateTime(QDate(2029, 2, 23), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-7") << "a=b; expires=29 23 Feb 1:1" << cookie; + + // 11 and 6 don't have 31 days + cookie.setExpirationDate(QDateTime(QDate(2031, 11, 06), QTime(1, 1, 0, 0), Qt::UTC)); + QTest::newRow("fuzz-8") << "a=b; expires=31 11 06 1:1" << cookie; + // two-digit years: // from 70 until 99, we assume 20th century + cookie.setExpirationDate(QDateTime(QDate(1999, 11, 9), QTime(23, 12, 40), Qt::UTC)); QTest::newRow("expiration-2digit1") << "a=b; expires=Wednesday, 09-Nov-99 23:12:40 GMT " << cookie; cookie.setExpirationDate(QDateTime(QDate(1970, 1, 1), QTime(23, 12, 40), Qt::UTC)); QTest::newRow("expiration-2digit2") << "a=b; expires=Thursday, 01-Jan-70 23:12:40 GMT " << cookie; @@ -340,6 +595,15 @@ void tst_QNetworkCookie::parseSingleCookie() result = QNetworkCookie::parseCookies(result.at(0).toRawForm()); QCOMPARE(result.count(), 1); + + // Drop any millisecond information, if there's any + QDateTime dt = expectedCookie.expirationDate(); + if (dt.isValid()) { + QTime t = dt.time(); + dt.setTime(t.addMSecs(-t.msec())); + expectedCookie.setExpirationDate(dt); + } + QCOMPARE(result.at(0), expectedCookie); } |