summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2012-03-20 00:05:55 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-03-20 19:13:43 (GMT)
commit3d6694b0c698fff63d11f8bb4aa995c1df882315 (patch)
treea46ccace647f23a65100cf69c951345aa6dea7ab /Swiften/Elements
parent3d27d98ccc232ae7bfacfd5a3f85f44b6c2e9cc9 (diff)
downloadswift-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/Elements')
-rw-r--r--Swiften/Elements/UnitTest/StanzaTest.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp
index 0319b52..4bb59b1 100644
--- a/Swiften/Elements/UnitTest/StanzaTest.cpp
+++ b/Swiften/Elements/UnitTest/StanzaTest.cpp
@@ -69,8 +69,8 @@ class StanzaTest : public CppUnit::TestFixture
void testConstructor_Copy() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>());
Message copy(m);
CPPUNIT_ASSERT(copy.getPayload<MyPayload1>());
@@ -81,7 +81,7 @@ class StanzaTest : public CppUnit::TestFixture
bool payloadAlive = true;
{
Message m;
- m.addPayload(boost::shared_ptr<DestroyingPayload>(new DestroyingPayload(&payloadAlive)));
+ m.addPayload(boost::make_shared<DestroyingPayload>(&payloadAlive));
}
CPPUNIT_ASSERT(!payloadAlive);
@@ -90,7 +90,7 @@ class StanzaTest : public CppUnit::TestFixture
void testDestructor_Copy() {
bool payloadAlive = true;
Message* m1 = new Message();
- m1->addPayload(boost::shared_ptr<DestroyingPayload>(new DestroyingPayload(&payloadAlive)));
+ m1->addPayload(boost::make_shared<DestroyingPayload>(&payloadAlive));
Message* m2 = new Message(*m1);
delete m1;
@@ -102,9 +102,9 @@ class StanzaTest : public CppUnit::TestFixture
void testGetPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>());
+ m.addPayload(boost::make_shared<MyPayload3>());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT(p);
@@ -112,8 +112,8 @@ class StanzaTest : public CppUnit::TestFixture
void testGetPayload_NoSuchPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload3>());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT(!p);
@@ -123,9 +123,9 @@ class StanzaTest : public CppUnit::TestFixture
Message m;
boost::shared_ptr<MyPayload2> payload1(new MyPayload2());
boost::shared_ptr<MyPayload2> payload2(new MyPayload2());
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
+ m.addPayload(boost::make_shared<MyPayload1>());
m.addPayload(payload1);
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload3>());
m.addPayload(payload2);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m.getPayloads<MyPayload2>().size());
@@ -136,11 +136,11 @@ class StanzaTest : public CppUnit::TestFixture
void testUpdatePayload_ExistingPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2("foo")));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>("foo"));
+ m.addPayload(boost::make_shared<MyPayload3>());
- m.updatePayload(boost::shared_ptr<MyPayload2>(new MyPayload2("bar")));
+ m.updatePayload(boost::make_shared<MyPayload2>("bar"));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
@@ -149,10 +149,10 @@ class StanzaTest : public CppUnit::TestFixture
void testUpdatePayload_NewPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload3>());
- m.updatePayload(boost::shared_ptr<MyPayload2>(new MyPayload2("bar")));
+ m.updatePayload(boost::make_shared<MyPayload2>("bar"));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size());
boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
@@ -161,26 +161,26 @@ class StanzaTest : public CppUnit::TestFixture
void testGetPayloadOfSameType() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload2>(new MyPayload2("foo")));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload2>("foo"));
+ m.addPayload(boost::make_shared<MyPayload3>());
- boost::shared_ptr<MyPayload2> payload(boost::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(boost::shared_ptr<MyPayload2>(new MyPayload2("bar")))));
+ boost::shared_ptr<MyPayload2> payload(boost::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(boost::make_shared<MyPayload2>("bar"))));
CPPUNIT_ASSERT(payload);
CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->text_);
}
void testGetPayloadOfSameType_NoSuchPayload() {
Message m;
- m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
- m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(boost::make_shared<MyPayload1>());
+ m.addPayload(boost::make_shared<MyPayload3>());
- CPPUNIT_ASSERT(!m.getPayloadOfSameType(boost::shared_ptr<MyPayload2>(new MyPayload2("bar"))));
+ CPPUNIT_ASSERT(!m.getPayloadOfSameType(boost::make_shared<MyPayload2>("bar")));
}
void testGetTimestamp() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1)));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestamp();
@@ -190,7 +190,7 @@ class StanzaTest : public CppUnit::TestFixture
void testGetTimestamp_TimestampWithFrom() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1), JID("foo@bar.com"))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestamp();
@@ -205,10 +205,10 @@ class StanzaTest : public CppUnit::TestFixture
void testGetTimestampFrom() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(0))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1), JID("foo1@bar.com"))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(2), JID("foo2@bar.com"))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(3), JID("foo3@bar.com"))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(0)));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo1@bar.com")));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(2), JID("foo2@bar.com")));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(3), JID("foo3@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestampFrom(JID("foo2@bar.com"));
@@ -218,8 +218,8 @@ class StanzaTest : public CppUnit::TestFixture
void testGetTimestampFrom_Fallsback() {
Message m;
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(1), JID("foo1@bar.com"))));
- m.addPayload(boost::shared_ptr<Delay>(new Delay(boost::posix_time::from_time_t(3), JID("foo3@bar.com"))));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo1@bar.com")));
+ m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(3), JID("foo3@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestampFrom(JID("foo2@bar.com"));