From 98cfcdaecad0fec2bb026f7cafe06491f1765c2e Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 9 Aug 2010 15:46:22 +0000 Subject: fix and test QDateTime representation in XML-RPC --- example/tests/tests.cpp | 26 +++++++++++++++++--------- example/tests/tests.h | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'example') diff --git a/example/tests/tests.cpp b/example/tests/tests.cpp index 43a7156d..b8ab9c63 100644 --- a/example/tests/tests.cpp +++ b/example/tests/tests.cpp @@ -323,15 +323,6 @@ void TestJingle::testRinging() static void checkVariant(const QVariant &value, const QByteArray &xml) { - // parse - QDomDocument doc; - QCOMPARE(doc.setContent(xml, true), true); - QDomElement element = doc.documentElement(); - QStringList errors; - QVariant test = XMLRPC::demarshall(element, errors); - QCOMPARE(errors, QStringList()); - QCOMPARE(test, value); - // serialise QBuffer buffer; buffer.open(QIODevice::ReadWrite); @@ -340,6 +331,17 @@ static void checkVariant(const QVariant &value, const QByteArray &xml) qDebug() << "expect " << xml; qDebug() << "writing" << buffer.data(); QCOMPARE(buffer.data(), xml); + + // parse + QDomDocument doc; + QCOMPARE(doc.setContent(xml, true), true); + QDomElement element = doc.documentElement(); + QStringList errors; + QVariant test = XMLRPC::demarshall(element, errors); + if (!errors.isEmpty()) + qDebug() << errors; + QCOMPARE(errors, QStringList()); + QCOMPARE(test, value); } void TestXmlRpc::testBool() @@ -351,6 +353,12 @@ void TestXmlRpc::testBool() QByteArray("true")); } +void TestXmlRpc::testDateTime() +{ + checkVariant(QDateTime(QDate(1998, 7, 17), QTime(14, 8, 55)), + QByteArray("1998-07-17T14:08:55")); +} + void TestXmlRpc::testDouble() { checkVariant(double(-12.214), diff --git a/example/tests/tests.h b/example/tests/tests.h index cacd72b0..1a536ffc 100644 --- a/example/tests/tests.h +++ b/example/tests/tests.h @@ -65,6 +65,7 @@ class TestXmlRpc : public QObject private slots: void testBool(); + void testDateTime(); void testDouble(); void testString(); }; -- cgit v1.2.3