diff options
Diffstat (limited to 'Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp')
-rw-r--r-- | Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp b/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp index 44242036..cd94ed8 100644 --- a/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp +++ b/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Isode Limited. + * Copyright (c) 2011-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,9 +8,9 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <Swiften/Base/Platform.h> +#include <Swiften/Elements/RawXMLPayload.h> #include <Swiften/Parser/GenericPayloadTreeParser.h> #include <Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h> -#include <Swiften/Elements/RawXMLPayload.h> using namespace Swift; @@ -22,44 +22,44 @@ template class __declspec(dllimport) Swift::GenericPayloadParser<RawXMLPayload>; #endif class GenericPayloadTreeParserTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(GenericPayloadTreeParserTest); - CPPUNIT_TEST(testTree); - CPPUNIT_TEST_SUITE_END(); - - public: - void testTree() { - MyParser testling; - - std::string data = "<topLevel xmlns='urn:test:top'><firstLevelInheritedEmpty/><firstLevelInherited><secondLevelMultiChildren num='1'/><secondLevelMultiChildren num='2'/></firstLevelInherited><firstLevelNS xmlns='urn:test:first'/></topLevel>"; - - PayloadParserTester tester(&testling); - tester.parse(data); - - ParserElement::ref tree = testling.tree; - - CPPUNIT_ASSERT_EQUAL(std::string("topLevel"), tree->getName()); - CPPUNIT_ASSERT_EQUAL(std::string("urn:test:top"), tree->getNamespace()); - CPPUNIT_ASSERT(tree->getChild("firstLevelInheritedEmpty", "urn:test:top")); - CPPUNIT_ASSERT(!*tree->getChild("firstLevelInheritedEmpty", "")); - CPPUNIT_ASSERT(tree->getChild("firstLevelInherited", "urn:test:top")); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top").size()); - CPPUNIT_ASSERT_EQUAL(std::string("1"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[0]->getAttributes().getAttribute("num")); - CPPUNIT_ASSERT_EQUAL(std::string("2"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[1]->getAttributes().getAttribute("num")); - CPPUNIT_ASSERT(tree->getChild("firstLevelNS", "urn:test:first")); - } - - private: - - - class MyParser : public GenericPayloadTreeParser<RawXMLPayload> - { - public: - virtual ~MyParser() {} - virtual void handleTree(ParserElement::ref root) { - tree = root; - } - ParserElement::ref tree; - }; + CPPUNIT_TEST_SUITE(GenericPayloadTreeParserTest); + CPPUNIT_TEST(testTree); + CPPUNIT_TEST_SUITE_END(); + + public: + void testTree() { + MyParser testling; + + std::string data = "<topLevel xmlns='urn:test:top'><firstLevelInheritedEmpty/><firstLevelInherited><secondLevelMultiChildren num='1'/><secondLevelMultiChildren num='2'/></firstLevelInherited><firstLevelNS xmlns='urn:test:first'/></topLevel>"; + + PayloadParserTester tester(&testling); + tester.parse(data); + + ParserElement::ref tree = testling.tree; + + CPPUNIT_ASSERT_EQUAL(std::string("topLevel"), tree->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("urn:test:top"), tree->getNamespace()); + CPPUNIT_ASSERT(tree->getChild("firstLevelInheritedEmpty", "urn:test:top")); + CPPUNIT_ASSERT(!*tree->getChild("firstLevelInheritedEmpty", "")); + CPPUNIT_ASSERT(tree->getChild("firstLevelInherited", "urn:test:top")); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top").size()); + CPPUNIT_ASSERT_EQUAL(std::string("1"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[0]->getAttributes().getAttribute("num")); + CPPUNIT_ASSERT_EQUAL(std::string("2"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[1]->getAttributes().getAttribute("num")); + CPPUNIT_ASSERT(tree->getChild("firstLevelNS", "urn:test:first")); + } + + private: + + + class MyParser : public GenericPayloadTreeParser<RawXMLPayload> + { + public: + virtual ~MyParser() {} + virtual void handleTree(ParserElement::ref root) { + tree = root; + } + ParserElement::ref tree; + }; }; |