From 9a1b98eba567366519e58481368cd8b5a411d1a8 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Sat, 21 Jul 2012 11:07:50 +0200 Subject: improve SASL stanza test coverage --- tests/sasl.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tests/sasl.cpp') diff --git a/tests/sasl.cpp b/tests/sasl.cpp index 46f5f22b..e874e120 100644 --- a/tests/sasl.cpp +++ b/tests/sasl.cpp @@ -74,6 +74,32 @@ void tst_QXmppSasl::testAuth() serializePacket(auth, xml); } +void tst_QXmppSasl::testChallenge_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("value"); + + QTest::newRow("empty") + << QByteArray("") + << QByteArray(); + + QTest::newRow("value") + << QByteArray("AGZvbwBiYXI=") + << QByteArray("\0foo\0bar", 8); +} + +void tst_QXmppSasl::testChallenge() +{ + QFETCH(QByteArray, xml); + QFETCH(QByteArray, value); + + // no condition + QXmppSaslChallenge challenge; + parsePacket(challenge, xml); + QCOMPARE(challenge.value(), value); + serializePacket(challenge, xml); +} + void tst_QXmppSasl::testFailure() { // no condition @@ -91,6 +117,32 @@ void tst_QXmppSasl::testFailure() serializePacket(failure2, xml2); } +void tst_QXmppSasl::testResponse_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("value"); + + QTest::newRow("empty") + << QByteArray("") + << QByteArray(); + + QTest::newRow("value") + << QByteArray("AGZvbwBiYXI=") + << QByteArray("\0foo\0bar", 8); +} + +void tst_QXmppSasl::testResponse() +{ + QFETCH(QByteArray, xml); + QFETCH(QByteArray, value); + + // no condition + QXmppSaslResponse response; + parsePacket(response, xml); + QCOMPARE(response.value(), value); + serializePacket(response, xml); +} + void tst_QXmppSasl::testSuccess() { const QByteArray xml = ""; -- cgit v1.2.3