Commit c404c304 authored by Laurent Montel's avatar Laurent Montel 😁

improve autotests

parent 3d24a06d
......@@ -42,4 +42,90 @@ void VCardLineTest::shouldHaveDefaultValue()
QVERIFY(line.value().isNull());
}
void VCardLineTest::shouldAssignValues()
{
KContacts::VCardLine line;
const QString identifier(QStringLiteral("foo"));
const QString group(QStringLiteral("bla"));
line.setIdentifier(identifier);
line.setGroup(group);
QMap<QString, QString> map;
for(int i = 0; i < 5; ++i) {
map.insert(QStringLiteral("foo%1").arg(i), QStringLiteral("bla%1").arg(i));
line.addParameter(QStringLiteral("foo%1").arg(i), QStringLiteral("bla%1").arg(i));
}
const QVariant valueVariant = QVariant(QStringLiteral("a"));
line.setValue(valueVariant);
QVERIFY(!line.parameterList().isEmpty());
QCOMPARE(line.parameterList(), QStringList() << map.keys());
QCOMPARE(line.identifier(), identifier);
QCOMPARE(line.group(), group);
QCOMPARE(line.value(), valueVariant);
}
void VCardLineTest::shouldCopyValue()
{
KContacts::VCardLine line;
const QString identifier(QStringLiteral("foo"));
const QString group(QStringLiteral("bla"));
line.setIdentifier(identifier);
line.setGroup(group);
QMap<QString, QString> map;
for(int i = 0; i < 5; ++i) {
map.insert(QStringLiteral("foo%1").arg(i), QStringLiteral("bla%1").arg(i));
line.addParameter(QStringLiteral("foo%1").arg(i), QStringLiteral("bla%1").arg(i));
}
const QVariant valueVariant = QVariant(QStringLiteral("a"));
line.setValue(valueVariant);
QVERIFY(!line.parameterList().isEmpty());
QCOMPARE(line.parameterList(), QStringList() << map.keys());
QCOMPARE(line.identifier(), identifier);
QCOMPARE(line.group(), group);
QCOMPARE(line.value(), valueVariant);
KContacts::VCardLine copyLine(line);
QVERIFY(!copyLine.parameterList().isEmpty());
QCOMPARE(copyLine.parameterList(), QStringList() << map.keys());
QCOMPARE(copyLine.identifier(), identifier);
QCOMPARE(copyLine.group(), group);
QCOMPARE(copyLine.value(), valueVariant);
}
void VCardLineTest::shouldEqualValue()
{
KContacts::VCardLine line;
const QString identifier(QStringLiteral("foo"));
const QString group(QStringLiteral("bla"));
line.setIdentifier(identifier);
line.setGroup(group);
QMap<QString, QString> map;
for(int i = 0; i < 5; ++i) {
map.insert(QStringLiteral("foo%1").arg(i), QStringLiteral("bla%1").arg(i));
line.addParameter(QStringLiteral("foo%1").arg(i), QStringLiteral("bla%1").arg(i));
}
const QVariant valueVariant = QVariant(QStringLiteral("a"));
line.setValue(valueVariant);
QVERIFY(!line.parameterList().isEmpty());
QCOMPARE(line.parameterList(), QStringList() << map.keys());
QCOMPARE(line.identifier(), identifier);
QCOMPARE(line.group(), group);
QCOMPARE(line.value(), valueVariant);
KContacts::VCardLine copyLine(line);
QVERIFY(line == copyLine);
}
QTEST_MAIN(VCardLineTest)
......@@ -32,6 +32,9 @@ public:
~VCardLineTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignValues();
void shouldCopyValue();
void shouldEqualValue();
};
#endif // VCARDLINETEST_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