Commit 93cbe318 authored by Laurent Montel's avatar Laurent Montel 😁

Add query test

parent 1a93f575
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "requesttest.h" #include "requesttest.h"
#include "../request.h" #include "../request.h"
#include <qtest_kde.h> #include <qtest_kde.h>
#include <KUrl>
RequestTest::RequestTest(QObject *parent) RequestTest::RequestTest(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
...@@ -43,4 +43,37 @@ void RequestTest::shouldHaveDefaultValue() ...@@ -43,4 +43,37 @@ void RequestTest::shouldHaveDefaultValue()
QCOMPARE(request.size(), static_cast<unsigned int>(0)); QCOMPARE(request.size(), static_cast<unsigned int>(0));
} }
void RequestTest::shouldParseRequest_data()
{
QTest::addColumn<KUrl>("smtpurl");
QTest::addColumn<QString>("to");
QTest::addColumn<QString>("from");
QTest::addColumn<QString>("cc");
QTest::addColumn<QString>("bcc");
QTest::addColumn<unsigned int>("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<unsigned int>(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) QTEST_KDEMAIN(RequestTest, NoGUI)
...@@ -28,6 +28,8 @@ public: ...@@ -28,6 +28,8 @@ public:
~RequestTest(); ~RequestTest();
private Q_SLOTS: private Q_SLOTS:
void shouldHaveDefaultValue(); void shouldHaveDefaultValue();
void shouldParseRequest_data();
void shouldParseRequest();
}; };
#endif // REQUESTTEST_H #endif // REQUESTTEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment