diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-09 15:46:22 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-09 15:46:22 +0000 |
| commit | 98cfcdaecad0fec2bb026f7cafe06491f1765c2e (patch) | |
| tree | ab18567e10b577d71aecd800ea71cbf9cdd86120 | |
| parent | ef0111fbe76e1556028c302c1fd4c804cccf5b76 (diff) | |
| download | qxmpp-98cfcdaecad0fec2bb026f7cafe06491f1765c2e.tar.gz | |
fix and test QDateTime representation in XML-RPC
| -rw-r--r-- | example/tests/tests.cpp | 26 | ||||
| -rw-r--r-- | example/tests/tests.h | 1 | ||||
| -rw-r--r-- | source/xmlrpc.cpp | 2 |
3 files changed, 19 insertions, 10 deletions
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("<value><boolean>true</boolean></value>")); } +void TestXmlRpc::testDateTime() +{ + checkVariant(QDateTime(QDate(1998, 7, 17), QTime(14, 8, 55)), + QByteArray("<value><dateTime.iso8601>1998-07-17T14:08:55</dateTime.iso8601></value>")); +} + 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(); }; diff --git a/source/xmlrpc.cpp b/source/xmlrpc.cpp index abf3dcc9..e64a0620 100644 --- a/source/xmlrpc.cpp +++ b/source/xmlrpc.cpp @@ -115,7 +115,7 @@ QVariant XMLRPC::demarshall(const QDomElement &elem, QStringList &errors) } else if( typeName == "boolean" ) return QVariant( ( typeData.text().toLower() == "true" || typeData.text() == "1")?true:false ); - else if( typeName == "datetime" || typeName == "dateTime.iso8601" ) + else if( typeName == "datetime" || typeName == "datetime.iso8601" ) return QVariant( QDateTime::fromString( typeData.text(), Qt::ISODate ) ); else if( typeName == "array" ) { |
