/* * Copyright (c) 2010-2012 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include #include #include #include #include #include using namespace Swift; class ErrorSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ErrorSerializerTest); CPPUNIT_TEST(testSerialize); CPPUNIT_TEST(testSerialize_Payload); CPPUNIT_TEST_SUITE_END(); public: void testSerialize() { ErrorSerializer testling(&serializers); boost::shared_ptr error(new ErrorPayload(ErrorPayload::BadRequest, ErrorPayload::Cancel, "My Error")); CPPUNIT_ASSERT_EQUAL(std::string("My Error"), testling.serialize(error)); } void testSerialize_Payload() { ErrorSerializer testling(&serializers); boost::shared_ptr error = boost::make_shared(); error->setPayload(boost::make_shared()); CPPUNIT_ASSERT_EQUAL(std::string( "" ), testling.serialize(error)); } private: FullPayloadSerializerCollection serializers; }; CPPUNIT_TEST_SUITE_REGISTRATION(ErrorSerializerTest);