#include #include #include "Swiften/Parser/SerializingParser.h" #include "Swiften/Parser/UnitTest/StanzaParserTester.h" using namespace Swift; class SerializingParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(SerializingParserTest); CPPUNIT_TEST(testParse); CPPUNIT_TEST(testParse_Empty); CPPUNIT_TEST(testParse_ToplevelCharacterData); CPPUNIT_TEST_SUITE_END(); public: SerializingParserTest() {} void testParse() { SerializingParser testling; ParserTester parser(&testling); CPPUNIT_ASSERT(parser.parse( "" "Hello<&World" "" "foobarbaz" "" "")); CPPUNIT_ASSERT_EQUAL(String( "" "Hello<&World" "foobarbaz" ""), testling.getResult()); } void testParse_Empty() { SerializingParser testling; CPPUNIT_ASSERT_EQUAL(String(""), testling.getResult()); } void testParse_ToplevelCharacterData() { SerializingParser testling; AttributeMap attributes; testling.handleCharacterData("foo"); testling.handleStartElement("message", "", attributes); testling.handleEndElement("message", ""); testling.handleCharacterData("bar"); CPPUNIT_ASSERT_EQUAL(String(""), testling.getResult()); } }; CPPUNIT_TEST_SUITE_REGISTRATION(SerializingParserTest);