From e16866e072f94410321d70daedbcb855ea878cac Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 6 Nov 2011 15:56:40 -0600 Subject: Actually move the kde files that were renamed in the last commit --- tdecore/tests/krfcdatetest.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tdecore/tests/krfcdatetest.cpp (limited to 'tdecore/tests/krfcdatetest.cpp') diff --git a/tdecore/tests/krfcdatetest.cpp b/tdecore/tests/krfcdatetest.cpp new file mode 100644 index 000000000..368a1106f --- /dev/null +++ b/tdecore/tests/krfcdatetest.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +bool check(TQString txt, time_t a, time_t b) +{ + if (a == b) { + kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; + } + else { + kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; + exit(1); + } + return true; +} + +int main(int argc, char *argv[]) +{ + KApplication app(argc,argv,"kurltest",false,false); + + time_t a; + time_t b; + + // From http://www.w3.org/TR/NOTE-datetime + b = KRFCDate::parseDateISO8601("1994-11-05T13:15:30Z"); + a = KRFCDate::parseDateISO8601("1994-11-05T08:15:30-05:00"); + check( "1994-11-05T08:15:30-05:00", a, b); + + a = KRFCDate::parseDateISO8601("1994-11-05T18:15:30+05:00"); + check( "1994-11-05T18:15:30+05:00", a, b); + + a = KRFCDate::parseDate("Thu Nov 5 1994 18:15:30 GMT+0500"); + check( "Thu Nov 5 1994 18:15:30 GMT+0500", a, b); + + a = KRFCDate::parseDate("Thu Nov 5 1994 18:15:30 GMT+05:00"); + check( "Thu Nov 5 1994 18:15:30 GMT+05:00", a, b); + + a = KRFCDate::parseDate("Wednesday, 05-Nov-94 13:15:30 GMT"); + check( "Wednesday, 05-Nov-94 13:15:30 GMT", a, b); + + a = KRFCDate::parseDate("Wed, 05-Nov-1994 13:15:30 GMT"); + check( "Wed, 05-Nov-1994 13:15:30 GMT", a, b); + + a = KRFCDate::parseDate("Wed, 05-November-1994 13:15:30 GMT"); + check( "Wed, 05-November-1994 13:15:30 GMT", a, b); + + b = KRFCDate::parseDateISO8601("1994-01-01T12:00:00"); + a = KRFCDate::parseDateISO8601("1994"); + check( "1994", a, b ); + + a = KRFCDate::parseDateISO8601("1994-01"); + check( "1994-01", a, b ); + + a = KRFCDate::parseDateISO8601("1994-01-01"); + check( "1994-01-01", a, b ); + + b = 0; + + // pass RFC date to ISO parser + a = KRFCDate::parseDateISO8601("Thu, 01 Jan 2004 19:48:21 GMT"); + check("pass RFC date \"Thu, 01 Jan 2004 19:48:21 GMT\" to parseDateISO8601", a, b); + + // pass ISO date to RFC parser + a = KRFCDate::parseDate("1994-01-01T12:00:00"); + check("pass ISO date \"1994-01-01T12:00:00\" to parseDate()", a, b); + + // empty/null strings + + check("parseDateISO8601(TQString())", KRFCDate::parseDateISO8601(TQString()), b); + check("parseDateISO8601(\"\")", KRFCDate::parseDateISO8601(""), b); + check("parseDate(TQString())", KRFCDate::parseDate(TQString()), b); + check("parseDate(\"\")", KRFCDate::parseDate(""), b); + + printf("\nTest OK !\n"); +} + -- cgit v1.2.1