diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
commit | f53a1ef582494458301b97bf6e546be52d7ff7e8 (patch) | |
tree | 7571b5cbcbd8a8f1dd1c966c9045b6cb69f0e295 /Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp | |
parent | 638345680d72ca6acaf123f2c8c1c391f696e371 (diff) | |
download | swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.zip swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.tar.bz2 |
Moving submodule contents back.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp')
-rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp new file mode 100644 index 0000000..3fbf27a --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp @@ -0,0 +1,64 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include "Swiften/Parser/PayloadParsers/StorageParser.h" +#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" + +using namespace Swift; + +class StorageParserTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(StorageParserTest); + CPPUNIT_TEST(testParse_Conference); + CPPUNIT_TEST(testParse_MultipleConferences); + CPPUNIT_TEST_SUITE_END(); + + public: + StorageParserTest() {} + + void testParse_Conference() { + PayloadsParserTester parser; + + CPPUNIT_ASSERT(parser.parse( + "<storage xmlns='storage:bookmarks'>" + "<conference " + "name='Council of Oberon' " + "autojoin='true' jid='council@conference.underhill.org'>" + "<nick>Puck</nick>" + "<password>MyPass</password>" + "</conference>" + "</storage>")); + + Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get()); + std::vector<Storage::Conference> conferences = payload->getConferences(); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(conferences.size())); + CPPUNIT_ASSERT_EQUAL(String("Council of Oberon"), conferences[0].name); + CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), conferences[0].jid); + CPPUNIT_ASSERT(conferences[0].autoJoin); + CPPUNIT_ASSERT_EQUAL(String("Puck"), conferences[0].nick); + CPPUNIT_ASSERT_EQUAL(String("MyPass"), conferences[0].password); + } + + void testParse_MultipleConferences() { + PayloadsParserTester parser; + + CPPUNIT_ASSERT(parser.parse( + "<storage xmlns='storage:bookmarks'>" + "<conference " + "name='Council of Oberon' " + "jid='council@conference.underhill.org' />" + "<conference " + "name='Tea party' " + "jid='teaparty@wonderland.lit' />" + "</storage>")); + + Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get()); + std::vector<Storage::Conference> conferences = payload->getConferences(); + CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(conferences.size())); + CPPUNIT_ASSERT_EQUAL(String("Council of Oberon"), conferences[0].name); + CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), conferences[0].jid); + CPPUNIT_ASSERT_EQUAL(String("Tea party"), conferences[1].name); + CPPUNIT_ASSERT_EQUAL(JID("teaparty@wonderland.lit"), conferences[1].jid); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(StorageParserTest); |