diff options
| author | Linus Jahn <lnj@kaidan.im> | 2021-07-31 12:49:59 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-08-01 17:31:51 +0200 |
| commit | 95795726ade8071fea23dee83b6a6c5a9c122fee (patch) | |
| tree | d7a29bec3079005c23d4406556b915f34db26f19 /tests | |
| parent | 3041ac29ecaf9d72393b9dc1b28faa44201cf44b (diff) | |
| download | qxmpp-95795726ade8071fea23dee83b6a6c5a9c122fee.tar.gz | |
tests: util: Allow using ' instead of " in xml
serializePacket now accepts both `'` and `"`.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/qxmpparchiveiq/tst_qxmpparchiveiq.cpp | 4 | ||||
| -rw-r--r-- | tests/qxmppmessage/tst_qxmppmessage.cpp | 16 | ||||
| -rw-r--r-- | tests/util.h | 11 |
3 files changed, 18 insertions, 13 deletions
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() ">" "<from secs=\"0\"><body>Art thou not Romeo, and a Montague?</body></from>" "<to secs=\"11\"><body>Neither, fair saint, if either thee dislike.</body></to>" - "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" + "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" "</chat>" "</iq>") << -1; @@ -110,7 +110,7 @@ void tst_QXmppArchiveIq::testArchiveChat_data() ">" "<from secs=\"0\"><body>Art thou not Romeo, and a Montague?</body></from>" "<to secs=\"11\"><body>Neither, fair saint, if either thee dislike.</body></to>" - "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" + "<from secs=\"7\"><body>How cam'st thou hither, tell me, and wherefore?</body></from>" "<set xmlns=\"http://jabber.org/protocol/rsm\">" "<count>3</count>" "</set>" 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( "<message id=\"richard2-4.1.247\" to=\"kingrichard@royalty.england.lit/throne\" from=\"northumberland@shakespeare.lit/westminster\" type=\"normal\">" - "<body>My lord, dispatch; read o'er these articles.</body>" + "<body>My lord, dispatch; read o'er these articles.</body>" "<request xmlns=\"urn:xmpp:receipts\"/>" "</message>"); @@ -469,7 +469,7 @@ void tst_QXmppMessage::testSubextensions() "id=\"8a54s\" " "to=\"romeo@montague.lit/orchard\" " "type=\"chat\">" - "<body>What man art thou that thus bescreen'd in night so stumblest on my counsel?</body>" + "<body>What man art thou that thus bescreen'd in night so stumblest on my counsel?</body>" "</message>" "</forwarded>" "</result>" @@ -491,7 +491,7 @@ void tst_QXmppMessage::testChatMarkers() "id='message-1' " "to='ingrichard@royalty.england.lit/throne'>" "<thread>sleeping</thread>" - "<body>My lord, dispatch; read o'er these articles.</body>" + "<body>My lord, dispatch; read o'er these articles.</body>" "<markable xmlns='urn:xmpp:chat-markers:0'/>" "</message>"); @@ -673,7 +673,7 @@ void tst_QXmppMessage::testPrivateMessage() { const QByteArray xml = QByteArrayLiteral( "<message type=\"chat\">" - "<body>My lord, dispatch; read o'er these articles.</body>" + "<body>My lord, dispatch; read o'er these articles.</body>" "<private xmlns=\"urn:xmpp:carbons:2\"/>" "</message>"); @@ -758,7 +758,7 @@ void tst_QXmppMessage::testMix() "<message to=\"hag66@shakespeare.example\" " "from=\"coven@mix.shakespeare.example/123456\" " "type=\"groupchat\">" - "<body>Harpier cries: 'tis time, 'tis time.</body>" + "<body>Harpier cries: 'tis time, 'tis time.</body>" "<mix xmlns=\"urn:xmpp:mix:core:1\">" "<jid>hag66@shakespeare.example</jid>" "<nick>thirdwitch</nick>" @@ -783,7 +783,7 @@ void tst_QXmppMessage::testEme() // test standard encryption: OMEMO const QByteArray xmlOmemo( "<message to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"normal\">" - "<body>This message is encrypted with OMEMO, but your client doesn't seem to support that.</body>" + "<body>This message is encrypted with OMEMO, but your client doesn't seem to support that.</body>" "<encryption xmlns=\"urn:xmpp:eme:0\" namespace=\"eu.siacs.conversations.axolotl\"/>" "</message>"); @@ -797,7 +797,7 @@ void tst_QXmppMessage::testEme() // test custom encryption const QByteArray xmlCustom( "<message to=\"foo@example.com/QXmpp\" from=\"bar@example.com/QXmpp\" type=\"normal\">" - "<body>This message is encrypted with CustomCrypt, but your client doesn't seem to support that.</body>" + "<body>This message is encrypted with CustomCrypt, but your client doesn't seem to support that.</body>" "<encryption xmlns=\"urn:xmpp:eme:0\" namespace=\"im:example:customcrypt:1\" name=\"CustomCrypt\"/>" "</message>"); @@ -867,7 +867,7 @@ void tst_QXmppMessage::testProcessingHints() "<message to=\"juliet@capulet.lit/laptop\" " "from=\"romeo@montague.lit/laptop\" " "type=\"chat\">" - "<body>V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug</body>" + "<body>V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug</body>" "<no-permanent-store xmlns=\"urn:xmpp:hints\"/>" "<no-store xmlns=\"urn:xmpp:hints\"/>" "<no-copy xmlns=\"urn:xmpp:hints\"/>" 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<class T> @@ -66,10 +68,13 @@ static void parsePacket(T &packet, const QByteArray &xml) template<class T> 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<class T> |
