diff options
author | Tobias Markmann <tm@ayena.de> | 2012-03-20 00:05:55 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-03-20 19:13:43 (GMT) |
commit | 3d6694b0c698fff63d11f8bb4aa995c1df882315 (patch) | |
tree | a46ccace647f23a65100cf69c951345aa6dea7ab /Swiften/Queries/UnitTest | |
parent | 3d27d98ccc232ae7bfacfd5a3f85f44b6c2e9cc9 (diff) | |
download | swift-contrib-3d6694b0c698fff63d11f8bb4aa995c1df882315.zip swift-contrib-3d6694b0c698fff63d11f8bb4aa995c1df882315.tar.bz2 |
boost::shared_ptr<?>(new ?(...)) -> boost::make_shared<?>(...) transformation where possible.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/Queries/UnitTest')
-rw-r--r-- | Swiften/Queries/UnitTest/IQRouterTest.cpp | 23 | ||||
-rw-r--r-- | Swiften/Queries/UnitTest/RequestTest.cpp | 2 | ||||
-rw-r--r-- | Swiften/Queries/UnitTest/ResponderTest.cpp | 5 |
3 files changed, 16 insertions, 14 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 @@ -7,6 +7,7 @@ #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> @@ -43,7 +44,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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); @@ -54,9 +55,9 @@ class IQRouterTest : public CppUnit::TestFixture { 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); @@ -67,7 +68,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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); @@ -79,7 +80,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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); @@ -90,7 +91,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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>()); @@ -102,8 +103,8 @@ class IQRouterTest : public CppUnit::TestFixture { 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); @@ -113,7 +114,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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()); } @@ -121,7 +122,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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()); } @@ -131,7 +132,7 @@ class IQRouterTest : public CppUnit::TestFixture { 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()); } diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp index 52d62fb..cf9b381 100644 --- a/Swiften/Queries/UnitTest/RequestTest.cpp +++ b/Swiften/Queries/UnitTest/RequestTest.cpp @@ -130,7 +130,7 @@ class RequestTest : public CppUnit::TestFixture { testling.send(); boost::shared_ptr<IQ> error = createError(JID("foo@bar.com/baz"),"test-id"); - boost::shared_ptr<Payload> errorPayload = boost::shared_ptr<ErrorPayload>(new ErrorPayload(ErrorPayload::InternalServerError)); + boost::shared_ptr<Payload> errorPayload = boost::make_shared<ErrorPayload>(ErrorPayload::InternalServerError); error->addPayload(errorPayload); channel_->onIQReceived(error); diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index a256346..6d40b6c 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -7,6 +7,7 @@ #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/Responder.h> @@ -32,7 +33,7 @@ class ResponderTest : public CppUnit::TestFixture { void setUp() { channel_ = new DummyIQChannel(); router_ = new IQRouter(channel_); - payload_ = boost::shared_ptr<SoftwareVersion>(new SoftwareVersion("foo")); + payload_ = boost::make_shared<SoftwareVersion>("foo"); } void tearDown() { @@ -108,7 +109,7 @@ class ResponderTest : public CppUnit::TestFixture { void testHandleIQ_NoPayload() { MyResponder testling(router_); - CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(boost::shared_ptr<IQ>(new IQ(IQ::Get)))); + CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(boost::make_shared<IQ>(IQ::Get))); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.getPayloads_.size())); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.setPayloads_.size())); |