summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-01 17:23:49 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-04 08:28:23 (GMT)
commit741c45b74d5f634622eb5f757c49323274fb8937 (patch)
treeb9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swiften/Elements/UnitTest
parenteddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff)
downloadswift-741c45b74d5f634622eb5f757c49323274fb8937.zip
swift-741c45b74d5f634622eb5f757c49323274fb8937.tar.bz2
Modernize code to use C++11 shared_ptr instead of Boost's
This change was done by applying the following 'gsed' replacement calls to all source files: 's/\#include <boost\/shared_ptr\.hpp>/\#include <memory>/g' 's/\#include <boost\/enable_shared_from_this\.hpp>/\#include <memory>/g' 's/\#include <boost\/smart_ptr\/make_shared\.hpp>/\#include <memory>/g' 's/\#include <boost\/make_shared\.hpp>/\#include <memory>/g' 's/\#include <boost\/weak_ptr\.hpp>/\#include <memory>/g' 's/boost::make_shared/std::make_shared/g' 's/boost::dynamic_pointer_cast/std::dynamic_pointer_cast/g' 's/boost::shared_ptr/std::shared_ptr/g' 's/boost::weak_ptr/std::weak_ptr/g' 's/boost::enable_shared_from_this/std::enable_shared_from_this/g' The remaining issues have been fixed manually. Test-Information: Code builds on OS X 10.11.4 and unit tests pass. Change-Id: Ia7ae34eab869fb9ad6387a1348426b71ae4acd5f
Diffstat (limited to 'Swiften/Elements/UnitTest')
-rw-r--r--Swiften/Elements/UnitTest/FormTest.cpp13
-rw-r--r--Swiften/Elements/UnitTest/IQTest.cpp12
-rw-r--r--Swiften/Elements/UnitTest/StanzaTest.cpp81
3 files changed, 53 insertions, 53 deletions
diff --git a/Swiften/Elements/UnitTest/FormTest.cpp b/Swiften/Elements/UnitTest/FormTest.cpp
index 9255fa8..c728bde 100644
--- a/Swiften/Elements/UnitTest/FormTest.cpp
+++ b/Swiften/Elements/UnitTest/FormTest.cpp
@@ -4,8 +4,7 @@
* See the COPYING file for more information.
*/
-#include <boost/shared_ptr.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
+#include <memory>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
@@ -25,13 +24,13 @@ class FormTest : public CppUnit::TestFixture {
void testGetFormType() {
Form form;
- form.addField(boost::make_shared<FormField>(FormField::FixedType, "Foo"));
+ form.addField(std::make_shared<FormField>(FormField::FixedType, "Foo"));
- FormField::ref field = boost::make_shared<FormField>(FormField::HiddenType, "jabber:bot");
+ FormField::ref field = std::make_shared<FormField>(FormField::HiddenType, "jabber:bot");
field->setName("FORM_TYPE");
form.addField(field);
- form.addField(boost::make_shared<FormField>(FormField::FixedType, "Bar"));
+ form.addField(std::make_shared<FormField>(FormField::FixedType, "Bar"));
CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), form.getFormType());
}
@@ -39,7 +38,7 @@ class FormTest : public CppUnit::TestFixture {
void testGetFormType_InvalidFormType() {
Form form;
- FormField::ref field = boost::make_shared<FormField>(FormField::FixedType, "jabber:bot");
+ FormField::ref field = std::make_shared<FormField>(FormField::FixedType, "jabber:bot");
field->setName("FORM_TYPE");
form.addField(field);
@@ -49,7 +48,7 @@ class FormTest : public CppUnit::TestFixture {
void testGetFormType_NoFormType() {
Form form;
- form.addField(boost::make_shared<FormField>(FormField::FixedType, "Foo"));
+ form.addField(std::make_shared<FormField>(FormField::FixedType, "Foo"));
CPPUNIT_ASSERT_EQUAL(std::string(""), form.getFormType());
}
diff --git a/Swiften/Elements/UnitTest/IQTest.cpp b/Swiften/Elements/UnitTest/IQTest.cpp
index a88e2d6..ed98c75 100644
--- a/Swiften/Elements/UnitTest/IQTest.cpp
+++ b/Swiften/Elements/UnitTest/IQTest.cpp
@@ -4,7 +4,7 @@
* See the COPYING file for more information.
*/
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
@@ -26,8 +26,8 @@ class IQTest : public CppUnit::TestFixture
IQTest() {}
void testCreateResult() {
- boost::shared_ptr<Payload> payload(new SoftwareVersion("myclient"));
- boost::shared_ptr<IQ> iq(IQ::createResult(JID("foo@bar/fum"), "myid", payload));
+ std::shared_ptr<Payload> payload(new SoftwareVersion("myclient"));
+ std::shared_ptr<IQ> iq(IQ::createResult(JID("foo@bar/fum"), "myid", payload));
CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo());
CPPUNIT_ASSERT_EQUAL(std::string("myid"), iq->getID());
@@ -36,7 +36,7 @@ class IQTest : public CppUnit::TestFixture
}
void testCreateResult_WithoutPayload() {
- boost::shared_ptr<IQ> iq(IQ::createResult(JID("foo@bar/fum"), "myid"));
+ std::shared_ptr<IQ> iq(IQ::createResult(JID("foo@bar/fum"), "myid"));
CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo());
CPPUNIT_ASSERT_EQUAL(std::string("myid"), iq->getID());
@@ -44,11 +44,11 @@ class IQTest : public CppUnit::TestFixture
}
void testCreateError() {
- boost::shared_ptr<IQ> iq(IQ::createError(JID("foo@bar/fum"), "myid", ErrorPayload::BadRequest, ErrorPayload::Modify));
+ std::shared_ptr<IQ> iq(IQ::createError(JID("foo@bar/fum"), "myid", ErrorPayload::BadRequest, ErrorPayload::Modify));
CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo());
CPPUNIT_ASSERT_EQUAL(std::string("myid"), iq->getID());
- boost::shared_ptr<ErrorPayload> error(iq->getPayload<ErrorPayload>());
+ std::shared_ptr<ErrorPayload> error(iq->getPayload<ErrorPayload>());
CPPUNIT_ASSERT(error);
CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, error->getCondition());
CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, error->getType());
diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp
index 13c038c..6a45bd8 100644
--- a/Swiften/Elements/UnitTest/StanzaTest.cpp
+++ b/Swiften/Elements/UnitTest/StanzaTest.cpp
@@ -4,8 +4,9 @@
* See the COPYING file for more information.
*/
+#include <memory>
+
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/shared_ptr.hpp>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
@@ -70,8 +71,8 @@ class StanzaTest : public CppUnit::TestFixture
void testConstructor_Copy() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload2>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload2>());
Message copy(m);
CPPUNIT_ASSERT(copy.getPayload<MyPayload1>());
@@ -82,7 +83,7 @@ class StanzaTest : public CppUnit::TestFixture
bool payloadAlive = true;
{
Message m;
- m.addPayload(boost::make_shared<DestroyingPayload>(&payloadAlive));
+ m.addPayload(std::make_shared<DestroyingPayload>(&payloadAlive));
}
CPPUNIT_ASSERT(!payloadAlive);
@@ -91,7 +92,7 @@ class StanzaTest : public CppUnit::TestFixture
void testDestructor_Copy() {
bool payloadAlive = true;
Message* m1 = new Message();
- m1->addPayload(boost::make_shared<DestroyingPayload>(&payloadAlive));
+ m1->addPayload(std::make_shared<DestroyingPayload>(&payloadAlive));
Message* m2 = new Message(*m1);
delete m1;
@@ -103,30 +104,30 @@ class StanzaTest : public CppUnit::TestFixture
void testGetPayload() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload2>());
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload2>());
+ m.addPayload(std::make_shared<MyPayload3>());
- boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
+ std::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT(p);
}
void testGetPayload_NoSuchPayload() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload3>());
- boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
+ std::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT(!p);
}
void testGetPayloads() {
Message m;
- boost::shared_ptr<MyPayload2> payload1(new MyPayload2());
- boost::shared_ptr<MyPayload2> payload2(new MyPayload2());
- m.addPayload(boost::make_shared<MyPayload1>());
+ std::shared_ptr<MyPayload2> payload1(new MyPayload2());
+ std::shared_ptr<MyPayload2> payload2(new MyPayload2());
+ m.addPayload(std::make_shared<MyPayload1>());
m.addPayload(payload1);
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload3>());
m.addPayload(payload2);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m.getPayloads<MyPayload2>().size());
@@ -137,51 +138,51 @@ class StanzaTest : public CppUnit::TestFixture
void testUpdatePayload_ExistingPayload() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload2>("foo"));
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload2>("foo"));
+ m.addPayload(std::make_shared<MyPayload3>());
- m.updatePayload(boost::make_shared<MyPayload2>("bar"));
+ m.updatePayload(std::make_shared<MyPayload2>("bar"));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size());
- boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
+ std::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT_EQUAL(std::string("bar"), p->text_);
}
void testUpdatePayload_NewPayload() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload3>());
- m.updatePayload(boost::make_shared<MyPayload2>("bar"));
+ m.updatePayload(std::make_shared<MyPayload2>("bar"));
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size());
- boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
+ std::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>());
CPPUNIT_ASSERT_EQUAL(std::string("bar"), p->text_);
}
void testGetPayloadOfSameType() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload2>("foo"));
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload2>("foo"));
+ m.addPayload(std::make_shared<MyPayload3>());
- boost::shared_ptr<MyPayload2> payload(boost::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(boost::make_shared<MyPayload2>("bar"))));
+ std::shared_ptr<MyPayload2> payload(std::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(std::make_shared<MyPayload2>("bar"))));
CPPUNIT_ASSERT(payload);
CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->text_);
}
void testGetPayloadOfSameType_NoSuchPayload() {
Message m;
- m.addPayload(boost::make_shared<MyPayload1>());
- m.addPayload(boost::make_shared<MyPayload3>());
+ m.addPayload(std::make_shared<MyPayload1>());
+ m.addPayload(std::make_shared<MyPayload3>());
- CPPUNIT_ASSERT(!m.getPayloadOfSameType(boost::make_shared<MyPayload2>("bar")));
+ CPPUNIT_ASSERT(!m.getPayloadOfSameType(std::make_shared<MyPayload2>("bar")));
}
void testGetTimestamp() {
Message m;
- m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1)));
+ m.addPayload(std::make_shared<Delay>(boost::posix_time::from_time_t(1)));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestamp();
@@ -191,7 +192,7 @@ class StanzaTest : public CppUnit::TestFixture
void testGetTimestamp_TimestampWithFrom() {
Message m;
- m.addPayload(boost::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo@bar.com")));
+ m.addPayload(std::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo@bar.com")));
boost::optional<boost::posix_time::ptime> timestamp = m.getTimestamp();
@@ -206,10 +207,10 @@ class StanzaTest : public CppUnit::TestFixture
void testGetTimestampFrom() {
Message m;
- 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")));
+ m.addPayload(std::make_shared<Delay>(boost::posix_time::from_time_t(0)));
+ m.addPayload(std::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo1@bar.com")));
+ m.addPayload(std::make_shared<Delay>(boost::posix_time::from_time_t(2), JID("foo2@bar.com")));
+ m.addPayload(std::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"));
@@ -219,8 +220,8 @@ class StanzaTest : public CppUnit::TestFixture
void testGetTimestampFrom_Fallsback() {
Message m;
- 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")));
+ m.addPayload(std::make_shared<Delay>(boost::posix_time::from_time_t(1), JID("foo1@bar.com")));
+ m.addPayload(std::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"));