diff options
Diffstat (limited to 'Swiften/Queries/UnitTest/IQRouterTest.cpp')
-rw-r--r-- | Swiften/Queries/UnitTest/IQRouterTest.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Swiften/Queries/UnitTest/IQRouterTest.cpp b/Swiften/Queries/UnitTest/IQRouterTest.cpp index f06b967..ee27a67 100644 --- a/Swiften/Queries/UnitTest/IQRouterTest.cpp +++ b/Swiften/Queries/UnitTest/IQRouterTest.cpp @@ -1,18 +1,19 @@ /* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <boost/shared_ptr.hpp> +#include <boost/smart_ptr/make_shared.hpp> #include <boost/bind.hpp> #include <Swiften/Queries/IQHandler.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/Queries/DummyIQChannel.h> using namespace Swift; class IQRouterTest : public CppUnit::TestFixture { @@ -37,107 +38,107 @@ class IQRouterTest : public CppUnit::TestFixture { delete channel_; } void testRemoveHandler() { IQRouter testling(channel_); DummyIQHandler handler1(true, &testling); DummyIQHandler handler2(true, &testling); testling.removeHandler(&handler1); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(0, handler1.called); CPPUNIT_ASSERT_EQUAL(1, handler2.called); } void testRemoveHandler_AfterHandleIQ() { IQRouter testling(channel_); DummyIQHandler handler2(true, &testling); DummyIQHandler handler1(true, &testling); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); testling.removeHandler(&handler1); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(1, handler2.called); } void testHandleIQ_SuccesfulHandlerFirst() { IQRouter testling(channel_); DummyIQHandler handler2(false, &testling); DummyIQHandler handler1(true, &testling); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(0, handler2.called); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(channel_->iqs_.size())); } void testHandleIQ_SuccesfulHandlerLast() { IQRouter testling(channel_); DummyIQHandler handler2(true, &testling); DummyIQHandler handler1(false, &testling); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(1, handler2.called); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(channel_->iqs_.size())); } void testHandleIQ_NoSuccesfulHandler() { IQRouter testling(channel_); DummyIQHandler handler(false, &testling); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); CPPUNIT_ASSERT(channel_->iqs_[0]->getPayload<ErrorPayload>()); } void testHandleIQ_HandlerRemovedDuringHandle() { IQRouter testling(channel_); DummyIQHandler handler2(true, &testling); RemovingIQHandler handler1(&testling); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(2, handler2.called); } void testSendIQ_WithFrom() { IQRouter testling(channel_); testling.setFrom(JID("foo@bar.com/baz")); - testling.sendIQ(boost::shared_ptr<IQ>(new IQ())); + testling.sendIQ(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom()); } void testSendIQ_WithoutFrom() { IQRouter testling(channel_); - testling.sendIQ(boost::shared_ptr<IQ>(new IQ())); + testling.sendIQ(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(JID(), channel_->iqs_[0]->getFrom()); } void testHandleIQ_WithFrom() { IQRouter testling(channel_); testling.setFrom(JID("foo@bar.com/baz")); DummyIQHandler handler(false, &testling); - channel_->onIQReceived(boost::shared_ptr<IQ>(new IQ())); + channel_->onIQReceived(boost::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom()); } private: struct DummyIQHandler : public IQHandler { DummyIQHandler(bool handle, IQRouter* router) : handle(handle), router(router), called(0) { router->addHandler(this); } |