aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmppomemodata/tst_qxmppomemodata.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/qxmppomemodata/tst_qxmppomemodata.cpp b/tests/qxmppomemodata/tst_qxmppomemodata.cpp
index 4c4ed8e9..be89a93c 100644
--- a/tests/qxmppomemodata/tst_qxmppomemodata.cpp
+++ b/tests/qxmppomemodata/tst_qxmppomemodata.cpp
@@ -12,6 +12,32 @@
#include "util.h"
#include <QObject>
+///
+/// Serializes data and compares it to multiple XML representations.
+/// It fails if no comparison succeeds.
+///
+template<class T>
+static void serializePacket(T &packet, const QVector<QByteArray> &xmls)
+{
+ auto isSerializationSuccessful = false;
+ const auto data = packetToXml(packet);
+
+ for (const auto &xml : xmls) {
+ auto processedXml = xml;
+ processedXml.replace(u'\'', u'"');
+
+ qDebug() << "expect " << processedXml;
+ qDebug() << "writing" << data;
+
+ if (data == processedXml) {
+ isSerializationSuccessful = true;
+ break;
+ }
+ }
+
+ QVERIFY2(isSerializationSuccessful, "No XML data equals the serialized packet");
+}
+
class tst_QXmppOmemoData : public QObject
{
Q_OBJECT