summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Roster/UnitTest/RosterTest.cpp')
-rw-r--r--Swiften/Roster/UnitTest/RosterTest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/Swiften/Roster/UnitTest/RosterTest.cpp b/Swiften/Roster/UnitTest/RosterTest.cpp
index f9dff33..2697747 100644
--- a/Swiften/Roster/UnitTest/RosterTest.cpp
+++ b/Swiften/Roster/UnitTest/RosterTest.cpp
@@ -17,6 +17,9 @@ class RosterTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(RosterTest);
CPPUNIT_TEST(testGetGroup);
+ CPPUNIT_TEST(testRemoveContact);
+ CPPUNIT_TEST(testRemoveSecondContact);
+ CPPUNIT_TEST(testRemoveSecondContactSameBare);
CPPUNIT_TEST_SUITE_END();
private:
@@ -51,6 +54,36 @@ class RosterTest : public CppUnit::TestFixture
}
+ void testRemoveContact() {
+ roster_->addContact(jid1_, "Bert", "group1");
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+
+ roster_->removeContact(jid1_);
+ CPPUNIT_ASSERT_EQUAL(0, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ }
+
+ void testRemoveSecondContact() {
+ roster_->addContact(jid1_, "Bert", "group1");
+ roster_->addContact(jid2_, "Cookie", "group1");
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+
+ roster_->removeContact(jid2_);
+ CPPUNIT_ASSERT_EQUAL(1, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ }
+
+ void testRemoveSecondContactSameBare() {
+ JID jid4a("a@b/c");
+ JID jid4b("a@b/d");
+ roster_->addContact(jid4a, "Bert", "group1");
+ roster_->addContact(jid4b, "Cookie", "group1");
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+
+ roster_->removeContact(jid4b);
+ CPPUNIT_ASSERT_EQUAL(1, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(RosterTest);