From 88f6ce979e30c0d3e0412bc6811ccc9d69eff7f3 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 15:49:19 +0200 Subject: split QXmppResultSet tests out --- tests/all/all.pro | 2 - tests/all/rsm.cpp | 155 -------------------------- tests/all/rsm.h | 37 ------ tests/all/tests.cpp | 4 - tests/qxmppresultset/tst_qxmppresultset.cpp | 167 ++++++++++++++++++++++++++++ tests/tests.pro | 1 + 6 files changed, 168 insertions(+), 198 deletions(-) delete mode 100644 tests/all/rsm.cpp delete mode 100644 tests/all/rsm.h create mode 100644 tests/qxmppresultset/tst_qxmppresultset.cpp (limited to 'tests') diff --git a/tests/all/all.pro b/tests/all/all.pro index f2895f9c..a9dd56b0 100644 --- a/tests/all/all.pro +++ b/tests/all/all.pro @@ -8,7 +8,6 @@ SOURCES += \ register.cpp \ roster.cpp \ rpc.cpp \ - rsm.cpp \ stun.cpp \ tests.cpp HEADERS += \ @@ -16,7 +15,6 @@ HEADERS += \ register.h \ roster.h \ rpc.h \ - rsm.h \ stun.h \ tests.h diff --git a/tests/all/rsm.cpp b/tests/all/rsm.cpp deleted file mode 100644 index ca5438ad..00000000 --- a/tests/all/rsm.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2008-2012 The QXmpp developers - * - * Authors: - * Olivier Goffart - * 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 "QXmppResultSet.h" - -#include "rsm.h" -#include "util.h" - -void tst_QXmppResultSet::testQuery_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("max"); - QTest::addColumn("index"); - QTest::addColumn("before"); - QTest::addColumn("after"); - - QTest::newRow("Example 3") << - QByteArray("" - "10" - "") - << 10 << -1 << QString() << QString(); - - QTest::newRow("Example 5") << - QByteArray("" - "10" - "peterpan@neverland.lit" - "") - << 10 << -1 << QString() << QString("peterpan@neverland.lit"); - - QTest::newRow("Example 5") << - QByteArray("" - "10" - "peter@pixyland.org" - "") - << 10 << -1 << QString("peter@pixyland.org") << QString(); - - QTest::newRow("Example 11") << - QByteArray("" - "10" - "" - "") - << 10 << -1 << QString("") << QString(); - - QTest::newRow("Example 12") << - QByteArray("" - "10" - "371" - "") - << 10 << 371 << QString() << QString(); - - - QTest::newRow("Example 15") << - QByteArray("" - "0" - "") - << 0 << -1 << QString() << QString(); -} - -void tst_QXmppResultSet::testQuery() -{ - QFETCH(QByteArray, xml); - QFETCH(int, max); - QFETCH(int, index); - QFETCH(QString, before); - QFETCH(QString, after); - - QXmppResultSetQuery iq; - parsePacket(iq, xml); - QCOMPARE(iq.max(), max); - QCOMPARE(iq.index(), index); - QCOMPARE(iq.before(), before); - QCOMPARE(iq.before().isNull(), before.isNull()); - QCOMPARE(iq.after(), after); - QCOMPARE(iq.after().isNull(), after.isNull()); - serializePacket(iq, xml); -} - -void tst_QXmppResultSet::testReply_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("count"); - QTest::addColumn("index"); - QTest::addColumn("first"); - QTest::addColumn("last"); - - QTest::newRow("Example 4") << - QByteArray( "" - "stpeter@jabber.org" - "peterpan@neverland.lit" - "800" - "") - << 800 << 0 << QString("stpeter@jabber.org") << QString("peterpan@neverland.lit"); - - QTest::newRow("Example 6") << - QByteArray( "" - "stpeter@jabber.org" - "peterpan@neverland.lit" - "800" - "") - << 800 << 0 << QString("stpeter@jabber.org") << QString("peterpan@neverland.lit"); - QTest::newRow("Example 4") << - QByteArray( "" - "peter@pixyland.org" - "peter@rabbit.lit" - "800" - "") - << 800 << 10 << QString("peter@pixyland.org") << QString("peter@rabbit.lit"); - - QTest::newRow("Example 7") << - QByteArray( "" - "790" - "") - << 790 << -1 << QString() << QString(); -} - -void tst_QXmppResultSet::testReply() -{ - QFETCH(QByteArray, xml); - QFETCH(int, count); - QFETCH(int, index); - QFETCH(QString, first); - QFETCH(QString, last); - - QXmppResultSetReply iq; - parsePacket(iq, xml); - QCOMPARE(iq.count(), count); - QCOMPARE(iq.index(), index); - QCOMPARE(iq.first(), first); - QCOMPARE(iq.first().isNull(), first.isNull()); - QCOMPARE(iq.last(), last); - QCOMPARE(iq.last().isNull(), last.isNull()); - serializePacket(iq, xml); -} - diff --git a/tests/all/rsm.h b/tests/all/rsm.h deleted file mode 100644 index 120ea625..00000000 --- a/tests/all/rsm.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2008-2012 The QXmpp developers - * - * Authors: - * Olivier Goffart - * 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 - -class tst_QXmppResultSet : public QObject -{ - Q_OBJECT - -private slots: - void testQuery_data(); - void testQuery(); - void testReply_data(); - void testReply(); -}; - diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp index 3f3df8ed..6a17ce18 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -49,7 +49,6 @@ #include "register.h" #include "roster.h" #include "rpc.h" -#include "rsm.h" #include "sasl.h" #include "stun.h" #include "tests.h" @@ -897,9 +896,6 @@ int main(int argc, char *argv[]) tst_QXmppRegisterIq testRegister; errors += QTest::qExec(&testRegister); - tst_QXmppResultSet testRsm; - errors += QTest::qExec(&testRsm); - tst_QXmppRosterIq testRoster; errors += QTest::qExec(&testRoster); diff --git a/tests/qxmppresultset/tst_qxmppresultset.cpp b/tests/qxmppresultset/tst_qxmppresultset.cpp new file mode 100644 index 00000000..72e59fb4 --- /dev/null +++ b/tests/qxmppresultset/tst_qxmppresultset.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2008-2012 The QXmpp developers + * + * Authors: + * Olivier Goffart + * 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 +#include "QXmppResultSet.h" +#include "util.h" + +class tst_QXmppResultSet : public QObject +{ + Q_OBJECT + +private slots: + void testQuery_data(); + void testQuery(); + void testReply_data(); + void testReply(); +}; + +void tst_QXmppResultSet::testQuery_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("max"); + QTest::addColumn("index"); + QTest::addColumn("before"); + QTest::addColumn("after"); + + QTest::newRow("Example 3") << + QByteArray("" + "10" + "") + << 10 << -1 << QString() << QString(); + + QTest::newRow("Example 5") << + QByteArray("" + "10" + "peterpan@neverland.lit" + "") + << 10 << -1 << QString() << QString("peterpan@neverland.lit"); + + QTest::newRow("Example 5") << + QByteArray("" + "10" + "peter@pixyland.org" + "") + << 10 << -1 << QString("peter@pixyland.org") << QString(); + + QTest::newRow("Example 11") << + QByteArray("" + "10" + "" + "") + << 10 << -1 << QString("") << QString(); + + QTest::newRow("Example 12") << + QByteArray("" + "10" + "371" + "") + << 10 << 371 << QString() << QString(); + + + QTest::newRow("Example 15") << + QByteArray("" + "0" + "") + << 0 << -1 << QString() << QString(); +} + +void tst_QXmppResultSet::testQuery() +{ + QFETCH(QByteArray, xml); + QFETCH(int, max); + QFETCH(int, index); + QFETCH(QString, before); + QFETCH(QString, after); + + QXmppResultSetQuery iq; + parsePacket(iq, xml); + QCOMPARE(iq.max(), max); + QCOMPARE(iq.index(), index); + QCOMPARE(iq.before(), before); + QCOMPARE(iq.before().isNull(), before.isNull()); + QCOMPARE(iq.after(), after); + QCOMPARE(iq.after().isNull(), after.isNull()); + serializePacket(iq, xml); +} + +void tst_QXmppResultSet::testReply_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("count"); + QTest::addColumn("index"); + QTest::addColumn("first"); + QTest::addColumn("last"); + + QTest::newRow("Example 4") << + QByteArray( "" + "stpeter@jabber.org" + "peterpan@neverland.lit" + "800" + "") + << 800 << 0 << QString("stpeter@jabber.org") << QString("peterpan@neverland.lit"); + + QTest::newRow("Example 6") << + QByteArray( "" + "stpeter@jabber.org" + "peterpan@neverland.lit" + "800" + "") + << 800 << 0 << QString("stpeter@jabber.org") << QString("peterpan@neverland.lit"); + QTest::newRow("Example 4") << + QByteArray( "" + "peter@pixyland.org" + "peter@rabbit.lit" + "800" + "") + << 800 << 10 << QString("peter@pixyland.org") << QString("peter@rabbit.lit"); + + QTest::newRow("Example 7") << + QByteArray( "" + "790" + "") + << 790 << -1 << QString() << QString(); +} + +void tst_QXmppResultSet::testReply() +{ + QFETCH(QByteArray, xml); + QFETCH(int, count); + QFETCH(int, index); + QFETCH(QString, first); + QFETCH(QString, last); + + QXmppResultSetReply iq; + parsePacket(iq, xml); + QCOMPARE(iq.count(), count); + QCOMPARE(iq.index(), index); + QCOMPARE(iq.first(), first); + QCOMPARE(iq.first().isNull(), first.isNull()); + QCOMPARE(iq.last(), last); + QCOMPARE(iq.last().isNull(), last.isNull()); + serializePacket(iq, xml); +} + +QTEST_MAIN(tst_QXmppResultSet) +#include "tst_qxmppresultset.moc" diff --git a/tests/tests.pro b/tests/tests.pro index 20f2e8b2..03285789 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -5,6 +5,7 @@ SUBDIRS = \ qxmppiq \ qxmppmessage \ qxmpppresence \ + qxmppresultset \ qxmpprtppacket \ qxmppstanza \ qxmppvcardiq -- cgit v1.2.3