summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-01 08:48:42 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-01 09:24:28 (GMT)
commit2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch)
treed46294f35150c4f0f43deaf2d31fceaf945ae715 /Swiften/Controllers/UnitTest/NickResolverTest.cpp
downloadswift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip
swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2
Import.
Diffstat (limited to 'Swiften/Controllers/UnitTest/NickResolverTest.cpp')
-rw-r--r--Swiften/Controllers/UnitTest/NickResolverTest.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/Swiften/Controllers/UnitTest/NickResolverTest.cpp b/Swiften/Controllers/UnitTest/NickResolverTest.cpp
new file mode 100644
index 0000000..9c89d4d
--- /dev/null
+++ b/Swiften/Controllers/UnitTest/NickResolverTest.cpp
@@ -0,0 +1,62 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Controllers/NickResolver.h"
+#include "Swiften/Roster/XMPPRoster.h"
+
+using namespace Swift;
+
+class NickResolverTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(NickResolverTest);
+ CPPUNIT_TEST(testNoMatch);
+ CPPUNIT_TEST(testMatch);
+ CPPUNIT_TEST(testOverwrittenMatch);
+ CPPUNIT_TEST(testRemovedMatch);
+ CPPUNIT_TEST_SUITE_END();
+
+ std::vector<String> groups_;
+
+ public:
+ NickResolverTest() {}
+
+ void testNoMatch() {
+ boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster());
+ NickResolver resolver(xmppRoster);
+ JID testling("foo@bar/baz");
+
+ CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver.jidToNick(testling));
+ }
+
+ void testMatch() {
+ boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster());
+ NickResolver resolver(xmppRoster);
+ JID testling("foo@bar/baz");
+ xmppRoster->addContact(testling, "Test", groups_);
+
+ CPPUNIT_ASSERT_EQUAL(String("Test"), resolver.jidToNick(testling));
+ }
+
+ void testOverwrittenMatch() {
+ boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster());
+ NickResolver resolver(xmppRoster);
+ JID testling("foo@bar/baz");
+ xmppRoster->addContact(testling, "FailTest", groups_);
+ xmppRoster->addContact(testling, "Test", groups_);
+
+ CPPUNIT_ASSERT_EQUAL(String("Test"), resolver.jidToNick(testling));
+ }
+
+ void testRemovedMatch() {
+ boost::shared_ptr<XMPPRoster> xmppRoster(new XMPPRoster());
+ NickResolver resolver(xmppRoster);
+ JID testling("foo@bar/baz");
+ xmppRoster->addContact(testling, "FailTest", groups_);
+ xmppRoster->removeContact(testling);
+ CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver.jidToNick(testling));
+ }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(NickResolverTest);
+