Commit 20c7fcfd authored by Laurent Montel's avatar Laurent Montel 😁

Add unittest

parent 72f03799
......@@ -52,3 +52,5 @@ target_link_libraries(akonadi_mailfilter_agent
install(TARGETS akonadi_mailfilter_agent ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES mailfilteragent.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
install(FILES akonadi_mailfilter_agent.notifyrc DESTINATION "${DATA_INSTALL_DIR}/akonadi_mailfilter_agent" )
add_subdirectory(autotests)
set( mailfilteragent_pop3resourceattributetest_source pop3resourceattributetest.cpp ../pop3resourceattribute.cpp)
kde4_add_unit_test( pop3resourceattributetest ${mailfilteragent_pop3resourceattributetest_source})
target_link_libraries( pop3resourceattributetest ${QT_QTTEST_LIBRARY} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${KDEPIMLIBS_AKONADI_LIBS})
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pop3resourceattributetest.h"
#include "../pop3resourceattribute.h"
#include <qtest.h>
Pop3ResourceAttributeTest::Pop3ResourceAttributeTest(QObject *parent)
: QObject(parent)
{
}
Pop3ResourceAttributeTest::~Pop3ResourceAttributeTest()
{
}
void Pop3ResourceAttributeTest::shouldHaveDefaultValue()
{
Pop3ResourceAttribute attr;
QVERIFY(attr.pop3AccountName().isEmpty());
}
void Pop3ResourceAttributeTest::shouldAssignValue()
{
Pop3ResourceAttribute attr;
QString accountName;
attr.setPop3AccountName(accountName);
QCOMPARE(attr.pop3AccountName(), accountName);
accountName = QLatin1String("foo");
attr.setPop3AccountName(accountName);
QCOMPARE(attr.pop3AccountName(), accountName);
accountName.clear();
attr.setPop3AccountName(accountName);
QCOMPARE(attr.pop3AccountName(), accountName);
}
void Pop3ResourceAttributeTest::shouldDeserializeValue()
{
Pop3ResourceAttribute attr;
QString accountName = QLatin1String("foo");
attr.setPop3AccountName(accountName);
const QByteArray ba = attr.serialized();
Pop3ResourceAttribute result;
result.deserialize(ba);
QVERIFY(attr == result);
}
void Pop3ResourceAttributeTest::shouldCloneAttribute()
{
Pop3ResourceAttribute attr;
QString accountName = QLatin1String("foo");
attr.setPop3AccountName(accountName);
Pop3ResourceAttribute *result = attr.clone();
QVERIFY(attr == *result);
delete result;
}
QTEST_MAIN(Pop3ResourceAttributeTest)
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef POP3RESOURCEATTRIBUTETEST_H
#define POP3RESOURCEATTRIBUTETEST_H
#include <QObject>
class Pop3ResourceAttributeTest : public QObject
{
Q_OBJECT
public:
explicit Pop3ResourceAttributeTest(QObject *parent = 0);
~Pop3ResourceAttributeTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignValue();
void shouldDeserializeValue();
void shouldCloneAttribute();
};
#endif // POP3RESOURCEATTRIBUTETEST_H
......@@ -80,3 +80,8 @@ void Pop3ResourceAttribute::setPop3AccountName(const QString &accountName)
d->accountName = accountName;
}
bool Pop3ResourceAttribute::operator==(const Pop3ResourceAttribute &other) const
{
return d->accountName == other.pop3AccountName();
}
......@@ -36,6 +36,7 @@ public:
QString pop3AccountName() const;
void setPop3AccountName(const QString &accountName);
bool operator==(const Pop3ResourceAttribute &other) const;
private:
friend class Pop3ResourceAttributePrivate;
Pop3ResourceAttributePrivate * const d;
......
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