Commit 97e9cb90 authored by Laurent Montel's avatar Laurent Montel 😁

Improve unittest

parent e609c9f5
......@@ -36,9 +36,56 @@ void ImapAclAttributeTest::shouldHaveDefaultValue()
QVERIFY(attr.rights().isEmpty());
}
void ImapAclAttributeTest::shouldBuildAttribute()
{
QMap<QByteArray, KIMAP::Acl::Rights> right;
right.insert("test", KIMAP::Acl::Admin);
right.insert("foo", KIMAP::Acl::Admin);
QMap<QByteArray, KIMAP::Acl::Rights> oldright;
right.insert("test", KIMAP::Acl::Delete);
right.insert("foo", KIMAP::Acl::Delete);
PimCommon::ImapAclAttribute attr(right, oldright);
QCOMPARE(attr.oldRights(), oldright);
QCOMPARE(attr.rights(), right);
}
void ImapAclAttributeTest::shouldAssignValue()
{
PimCommon::ImapAclAttribute attr;
QMap<QByteArray, KIMAP::Acl::Rights> right;
right.insert("test", KIMAP::Acl::Admin);
right.insert("foo", KIMAP::Acl::Admin);
attr.setRights(right);
QCOMPARE(attr.rights(), right);
}
void ImapAclAttributeTest::shouldCloneAttr()
{
PimCommon::ImapAclAttribute attr;
QMap<QByteArray, KIMAP::Acl::Rights> right;
right.insert("test", KIMAP::Acl::Admin);
right.insert("foo", KIMAP::Acl::Admin);
attr.setRights(right);
PimCommon::ImapAclAttribute *clone = attr.clone();
QVERIFY(attr==*clone);
delete clone;
}
void ImapAclAttributeTest::shouldSerializedAttribute()
{
QMap<QByteArray, KIMAP::Acl::Rights> right;
right.insert("test", KIMAP::Acl::Admin);
right.insert("foo", KIMAP::Acl::Admin);
QMap<QByteArray, KIMAP::Acl::Rights> oldright;
right.insert("test", KIMAP::Acl::Delete);
right.insert("foo", KIMAP::Acl::Delete);
PimCommon::ImapAclAttribute attr(right, oldright);
const QByteArray ba = attr.serialized();
PimCommon::ImapAclAttribute result;
result.deserialize(ba);
QVERIFY(attr==result);
}
QTEST_KDEMAIN(ImapAclAttributeTest, NoGUI)
......@@ -27,7 +27,10 @@ public:
~ImapAclAttributeTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldBuildAttribute();
void shouldAssignValue();
void shouldCloneAttr();
void shouldSerializedAttribute();
};
#endif // IMAPACLATTRIBUTETEST_H
......@@ -55,7 +55,7 @@ QByteArray ImapAclAttribute::type() const
return sType;
}
Akonadi::Attribute *ImapAclAttribute::clone() const
ImapAclAttribute *ImapAclAttribute::clone() const
{
return new ImapAclAttribute( mRights, mOldRights );
}
......@@ -127,3 +127,9 @@ void ImapAclAttribute::deserialize( const QByteArray &data )
fillRightsMap( leftPart.split( '%' ), mRights );
fillRightsMap( rightPart.split( '%' ), mOldRights );
}
bool PimCommon::ImapAclAttribute::operator==(const PimCommon::ImapAclAttribute &other) const
{
return (oldRights() == other.oldRights()) && (rights() == other.rights());
}
......@@ -40,10 +40,11 @@ public:
QMap<QByteArray, KIMAP::Acl::Rights> rights() const;
QMap<QByteArray, KIMAP::Acl::Rights> oldRights() const;
QByteArray type() const;
Attribute *clone() const;
ImapAclAttribute *clone() const;
QByteArray serialized() const;
void deserialize( const QByteArray &data );
bool operator==(const ImapAclAttribute &other) const;
private:
QMap<QByteArray, KIMAP::Acl::Rights> mRights;
QMap<QByteArray, KIMAP::Acl::Rights> mOldRights;
......
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