diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-07-04 16:34:59 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-06-30 23:53:53 +0200 |
| commit | 2b63b9ce2b7e369ccf3e8365864ec2d4522db26e (patch) | |
| tree | 63f03f34bad8f065995e1dd8e37ee5fa92f3c1c7 | |
| parent | cbc61b2439a54fc31fd98cd5a0899d3e0aa9c5d9 (diff) | |
| download | qxmpp-2b63b9ce2b7e369ccf3e8365864ec2d4522db26e.tar.gz | |
tests: util: Add xmlToDom() helper
| -rw-r--r-- | tests/util.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/util.h b/tests/util.h index 61f50ee7..7711518e 100644 --- a/tests/util.h +++ b/tests/util.h @@ -4,6 +4,7 @@ * Authors: * Jeremy Lainé * Manjeet Dahiya + * Linus Jahn * * Source: * https://github.com/qxmpp-project/qxmpp @@ -27,14 +28,23 @@ #include <QDomDocument> #include <QtTest> +// QVERIFY2 with empty return value (return {};) +#define QVERIFY_RV(statement, description) \ + if (!QTest::qVerify(statement, #statement, description, __FILE__, __LINE__)) \ + return {}; + +QDomElement xmlToDom(const QByteArray &xml) +{ + QDomDocument doc; + QVERIFY_RV(doc.setContent(xml, true), "XML is not valid"); + return doc.documentElement(); +} + template<class T> static void parsePacket(T &packet, const QByteArray &xml) { //qDebug() << "parsing" << xml; - QDomDocument doc; - QCOMPARE(doc.setContent(xml, true), true); - QDomElement element = doc.documentElement(); - packet.parse(element); + packet.parse(xmlToDom(xml)); } template<class T> |
