From 93cbe3183a64b7efc71f66001dc51fbdd2e8bc75 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Tue, 9 Dec 2014 10:05:46 +0100 Subject: [PATCH] Add query test --- kioslave/smtp/tests/requesttest.cpp | 35 ++++++++++++++++++++++++++++- kioslave/smtp/tests/requesttest.h | 2 ++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/kioslave/smtp/tests/requesttest.cpp b/kioslave/smtp/tests/requesttest.cpp index 8e623c26c..fef7dd7ce 100644 --- a/kioslave/smtp/tests/requesttest.cpp +++ b/kioslave/smtp/tests/requesttest.cpp @@ -17,7 +17,7 @@ #include "requesttest.h" #include "../request.h" #include - +#include RequestTest::RequestTest(QObject *parent) : QObject(parent) { @@ -43,4 +43,37 @@ void RequestTest::shouldHaveDefaultValue() QCOMPARE(request.size(), static_cast(0)); } +void RequestTest::shouldParseRequest_data() +{ + QTest::addColumn("smtpurl"); + QTest::addColumn("to"); + QTest::addColumn("from"); + QTest::addColumn("cc"); + QTest::addColumn("bcc"); + QTest::addColumn("size"); + QTest::newRow("correct url") << KUrl(QLatin1String("smtps://smtp.kde.org:465/send?headers=0&from=foo%40kde.org&to=foo%40kde.org&size=617")) + << QString(QLatin1String("foo@kde.org")) + << QString(QLatin1String("foo@kde.org")) + << QString() + << QString() + << static_cast(617); +} + +void RequestTest::shouldParseRequest() +{ + QFETCH( KUrl, smtpurl ); + QFETCH( QString, to ); + QFETCH( QString, from ); + QFETCH( QString, cc ); + QFETCH( QString, bcc ); + QFETCH( unsigned int, size ); + + KioSMTP::Request request = KioSMTP::Request::fromURL(smtpurl); + QCOMPARE(request.to().join(QLatin1String(",")), to); + QCOMPARE(request.cc().join(QLatin1String(",")), cc); + QCOMPARE(request.fromAddress(), from); + QCOMPARE(request.bcc().join(QLatin1String(",")), bcc); + QCOMPARE(request.size(), size); +} + QTEST_KDEMAIN(RequestTest, NoGUI) diff --git a/kioslave/smtp/tests/requesttest.h b/kioslave/smtp/tests/requesttest.h index 141f61c0e..72d2afa6a 100644 --- a/kioslave/smtp/tests/requesttest.h +++ b/kioslave/smtp/tests/requesttest.h @@ -28,6 +28,8 @@ public: ~RequestTest(); private Q_SLOTS: void shouldHaveDefaultValue(); + void shouldParseRequest_data(); + void shouldParseRequest(); }; #endif // REQUESTTEST_H -- GitLab