From 95795726ade8071fea23dee83b6a6c5a9c122fee Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 31 Jul 2021 12:49:59 +0200 Subject: tests: util: Allow using ' instead of " in xml serializePacket now accepts both `'` and `"`. --- tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp | 4 ++-- tests/qxmppmessage/tst_qxmppmessage.cpp | 16 ++++++++-------- tests/util.h | 11 ++++++++--- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp b/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp index 5b2b9923..d84b639d 100644 --- a/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp +++ b/tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp @@ -95,7 +95,7 @@ void tst_QXmppArchiveIq::testArchiveChat_data() ">" "Art thou not Romeo, and a Montague?" "Neither, fair saint, if either thee dislike." - "How cam'st thou hither, tell me, and wherefore?" + "How cam'st thou hither, tell me, and wherefore?" "" "") << -1; @@ -110,7 +110,7 @@ void tst_QXmppArchiveIq::testArchiveChat_data() ">" "Art thou not Romeo, and a Montague?" "Neither, fair saint, if either thee dislike." - "How cam'st thou hither, tell me, and wherefore?" + "How cam'st thou hither, tell me, and wherefore?" "" "3" "" diff --git a/tests/qxmppmessage/tst_qxmppmessage.cpp b/tests/qxmppmessage/tst_qxmppmessage.cpp index 93ab7722..3b9f4208 100644 --- a/tests/qxmppmessage/tst_qxmppmessage.cpp +++ b/tests/qxmppmessage/tst_qxmppmessage.cpp @@ -221,7 +221,7 @@ void tst_QXmppMessage::testMessageReceipt() { const QByteArray xml( "" - "My lord, dispatch; read o'er these articles." + "My lord, dispatch; read o'er these articles." "" ""); @@ -469,7 +469,7 @@ void tst_QXmppMessage::testSubextensions() "id=\"8a54s\" " "to=\"romeo@montague.lit/orchard\" " "type=\"chat\">" - "What man art thou that thus bescreen'd in night so stumblest on my counsel?" + "What man art thou that thus bescreen'd in night so stumblest on my counsel?" "" "" "" @@ -491,7 +491,7 @@ void tst_QXmppMessage::testChatMarkers() "id='message-1' " "to='ingrichard@royalty.england.lit/throne'>" "sleeping" - "My lord, dispatch; read o'er these articles." + "My lord, dispatch; read o'er these articles." "" ""); @@ -673,7 +673,7 @@ void tst_QXmppMessage::testPrivateMessage() { const QByteArray xml = QByteArrayLiteral( "" - "My lord, dispatch; read o'er these articles." + "My lord, dispatch; read o'er these articles." "" ""); @@ -758,7 +758,7 @@ void tst_QXmppMessage::testMix() "" - "Harpier cries: 'tis time, 'tis time." + "Harpier cries: 'tis time, 'tis time." "" "hag66@shakespeare.example" "thirdwitch" @@ -783,7 +783,7 @@ void tst_QXmppMessage::testEme() // test standard encryption: OMEMO const QByteArray xmlOmemo( "" - "This message is encrypted with OMEMO, but your client doesn't seem to support that." + "This message is encrypted with OMEMO, but your client doesn't seem to support that." "" ""); @@ -797,7 +797,7 @@ void tst_QXmppMessage::testEme() // test custom encryption const QByteArray xmlCustom( "" - "This message is encrypted with CustomCrypt, but your client doesn't seem to support that." + "This message is encrypted with CustomCrypt, but your client doesn't seem to support that." "" ""); @@ -867,7 +867,7 @@ void tst_QXmppMessage::testProcessingHints() "" - "V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug" + "V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug" "" "" "" diff --git a/tests/util.h b/tests/util.h index 49f8e4d3..63b7a5dc 100644 --- a/tests/util.h +++ b/tests/util.h @@ -53,7 +53,9 @@ static QByteArray packetToXml(const T &packet) buffer.open(QIODevice::ReadWrite); QXmlStreamWriter writer(&buffer); packet.toXml(&writer); - return buffer.data(); + auto data = buffer.data(); + data.replace(u'\'', "'"); + return data; } template @@ -66,10 +68,13 @@ static void parsePacket(T &packet, const QByteArray &xml) template static void serializePacket(T &packet, const QByteArray &xml) { + auto processedXml = xml; + processedXml.replace(u'\'', u'"'); + const auto data = packetToXml(packet); - qDebug() << "expect " << xml; + qDebug() << "expect " << processedXml; qDebug() << "writing" << data; - QCOMPARE(data, xml); + QCOMPARE(data, processedXml); } template -- cgit v1.2.3