#include #include #include "Swiften/Parser/StreamFeaturesParser.h" #include "Swiften/Parser/UnitTest/ElementParserTester.h" using namespace Swift; class StreamFeaturesParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StreamFeaturesParserTest); CPPUNIT_TEST(testParse); CPPUNIT_TEST(testParse_Empty); CPPUNIT_TEST_SUITE_END(); public: StreamFeaturesParserTest() {} void testParse() { StreamFeaturesParser testling; ElementParserTester parser(&testling); CPPUNIT_ASSERT(parser.parse( "" "" "" "zlib" "lzw" "" "" "DIGEST-MD5" "PLAIN" "" "" "" "")); StreamFeatures* element = dynamic_cast(testling.getElement().get()); CPPUNIT_ASSERT(element->hasStartTLS()); CPPUNIT_ASSERT(element->hasSession()); CPPUNIT_ASSERT(element->hasResourceBind()); CPPUNIT_ASSERT(element->hasCompressionMethod("zlib")); CPPUNIT_ASSERT(element->hasCompressionMethod("lzw")); CPPUNIT_ASSERT(element->hasAuthenticationMechanisms()); CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5")); CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN")); } void testParse_Empty() { StreamFeaturesParser testling; ElementParserTester parser(&testling); parser.parse(""); StreamFeatures* element = dynamic_cast(testling.getElement().get()); CPPUNIT_ASSERT(!element->hasStartTLS()); CPPUNIT_ASSERT(!element->hasSession()); CPPUNIT_ASSERT(!element->hasResourceBind()); CPPUNIT_ASSERT(!element->hasAuthenticationMechanisms()); } }; CPPUNIT_TEST_SUITE_REGISTRATION(StreamFeaturesParserTest);