aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-07-21 19:35:06 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-07-21 19:35:06 +0200
commit92729ab1a47e45adf19d57d60427ff2e7858e0b4 (patch)
treef95dc7ff65b7e258a269a1ee7b2deab3e742c894 /tests
parentb7b646842fd13a1316c5def2c46f4c0025e03e2e (diff)
downloadqxmpp-92729ab1a47e45adf19d57d60427ff2e7858e0b4.tar.gz
add tests for QXmppIq
Diffstat (limited to 'tests')
-rw-r--r--tests/iq.cpp61
-rw-r--r--tests/iq.h34
-rw-r--r--tests/tests.cpp4
-rw-r--r--tests/tests.pro2
4 files changed, 101 insertions, 0 deletions
diff --git a/tests/iq.cpp b/tests/iq.cpp
new file mode 100644
index 00000000..6b4e3203
--- /dev/null
+++ b/tests/iq.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2008-2012 The QXmpp developers
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#include "QXmppIq.h"
+#include "iq.h"
+#include "tests.h"
+
+void tst_QXmppIq::testBasic_data()
+{
+ QTest::addColumn<QByteArray>("xml");
+ QTest::addColumn<int>("type");
+
+ QTest::newRow("get")
+ << QByteArray("<iq to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"get\"/>")
+ << int(QXmppIq::Get);
+
+ QTest::newRow("set")
+ << QByteArray("<iq to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"set\"/>")
+ << int(QXmppIq::Set);
+
+ QTest::newRow("result")
+ << QByteArray("<iq to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"result\"/>")
+ << int(QXmppIq::Result);
+
+ QTest::newRow("error")
+ << QByteArray("<iq to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"error\"/>")
+ << int(QXmppIq::Error);
+}
+
+void tst_QXmppIq::testBasic()
+{
+ QFETCH(QByteArray, xml);
+ QFETCH(int, type);
+
+ QXmppIq iq;
+ parsePacket(iq, xml);
+ QCOMPARE(iq.to(), QString("foo@example.com/QXmpp"));
+ QCOMPARE(iq.from(), QString("bar@example.com/QXmpp"));
+ QCOMPARE(int(iq.type()), type);
+ serializePacket(iq, xml);
+}
diff --git a/tests/iq.h b/tests/iq.h
new file mode 100644
index 00000000..5d382b31
--- /dev/null
+++ b/tests/iq.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2008-2012 The QXmpp developers
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#include <QObject>
+
+class tst_QXmppIq : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testBasic_data();
+ void testBasic();
+};
+
diff --git a/tests/tests.cpp b/tests/tests.cpp
index bf394d8e..652f95f3 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -50,6 +50,7 @@
#include "codec.h"
#include "dataform.h"
+#include "iq.h"
#include "jingle.h"
#include "message.h"
#include "presence.h"
@@ -1210,6 +1211,9 @@ int main(int argc, char *argv[])
tst_QXmppDataForm testDataForm;
errors += QTest::qExec(&testDataForm);
+ tst_QXmppIq testIq;
+ errors += QTest::qExec(&testIq);
+
TestJingle testJingle;
errors += QTest::qExec(&testJingle);
diff --git a/tests/tests.pro b/tests/tests.pro
index 9fabdf6f..d73311b6 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -7,6 +7,7 @@ TARGET = qxmpp-tests
RESOURCES += tests.qrc
SOURCES += \
dataform.cpp \
+ iq.cpp \
jingle.cpp \
message.cpp \
presence.cpp \
@@ -16,6 +17,7 @@ SOURCES += \
tests.cpp
HEADERS += \
dataform.h \
+ iq.h \
jingle.h \
message.h \
presence.h \