Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 78d2c8b2 authored by Laurent Montel's avatar Laurent Montel 😁

Improve unittest

parent e00a6b5d
......@@ -73,6 +73,15 @@ bool Email::operator==(const Email &other) const
return (d->parameters == other.parameters()) && (d->mail == other.mail()) && (d->preferred == other.preferred());
}
Email &Email::operator=(const Email &other)
{
if ( this != &other ) {
d = other.d;
}
return *this;
}
QString Email::toString() const
{
QString str;
......
......@@ -61,6 +61,8 @@ public:
bool operator==( const Email &other ) const;
Email &operator=( const Email &other );
QString toString() const;
private:
class Private;
......
......@@ -45,11 +45,17 @@ void EmailTest::shouldAssignValue()
{
const QString mail(QLatin1String("foo@kde.org"));
const bool preferred = true;
QMap<QString, QStringList> params;
params.insert(QLatin1String("Foo1"), QStringList()<< QLatin1String("bla1") <<QLatin1String("blo1"));
params.insert(QLatin1String("Foo2"), QStringList()<< QLatin1String("bla2") <<QLatin1String("blo2"));
KABC::Email email(mail, preferred);
email.setParameters(params);
QVERIFY(email.isValid());
QVERIFY(!email.mail().isEmpty());
QCOMPARE(email.mail(), mail);
QVERIFY(email.preferred());
QVERIFY(!email.parameters().isEmpty());
QCOMPARE(email.parameters(), params);
}
void EmailTest::shouldAssignExternal()
......@@ -73,6 +79,11 @@ void EmailTest::shouldSerialized()
const bool preferred = true;
email.setEmail(mail);
email.setPreferred(preferred);
QMap<QString, QStringList> params;
params.insert(QLatin1String("Foo1"), QStringList()<< QLatin1String("bla1") <<QLatin1String("blo1"));
params.insert(QLatin1String("Foo2"), QStringList()<< QLatin1String("bla2") <<QLatin1String("blo2"));
email.setParameters(params);
QByteArray data;
QDataStream s( &data, QIODevice::WriteOnly );
......@@ -84,4 +95,21 @@ void EmailTest::shouldSerialized()
QVERIFY( email == result );
}
void EmailTest::shouldEqualEmail()
{
KABC::Email email;
KABC::Email result;
const QString mail(QLatin1String("foo@kde.org"));
const bool preferred = true;
email.setEmail(mail);
email.setPreferred(preferred);
QMap<QString, QStringList> params;
params.insert(QLatin1String("Foo1"), QStringList()<< QLatin1String("bla1") <<QLatin1String("blo1"));
params.insert(QLatin1String("Foo2"), QStringList()<< QLatin1String("bla2") <<QLatin1String("blo2"));
email.setParameters(params);
result = email;
QVERIFY( email == result );
}
QTEST_KDEMAIN(EmailTest, NoGUI)
......@@ -35,6 +35,7 @@ private Q_SLOTS:
void shouldAssignValue();
void shouldAssignExternal();
void shouldSerialized();
void shouldEqualEmail();
};
#endif // EMAILTEST_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