diff options
author | Tobias Markmann <tm@ayena.de> | 2016-04-01 17:23:49 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-04-04 08:28:23 (GMT) |
commit | 741c45b74d5f634622eb5f757c49323274fb8937 (patch) | |
tree | b9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swiften/Roster/UnitTest | |
parent | eddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff) | |
download | swift-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/Roster/UnitTest')
-rw-r--r-- | Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp | 76 | ||||
-rw-r--r-- | Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp | 3 | ||||
-rw-r--r-- | Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h | 3 |
3 files changed, 41 insertions, 41 deletions
diff --git a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp index 6850c21..b646aba 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp @@ -4,7 +4,7 @@ * See the COPYING file for more information. */ -#include <boost/smart_ptr/make_shared.hpp> +#include <memory> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -61,10 +61,10 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { } void testGet_Response() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->requestRoster(); - boost::shared_ptr<RosterPayload> payload = boost::make_shared<RosterPayload>(); + std::shared_ptr<RosterPayload> payload = std::make_shared<RosterPayload>(); payload->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); payload->addItem(RosterItemPayload(jid2_, "Alice", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createResult("foo@bar.com", channel_->sentStanzas[0]->getID(), payload)); @@ -79,13 +79,13 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { controller.requestRoster(); - channel_->onIQReceived(IQ::createResult(JID("baz@fum.com/dum"), channel_->sentStanzas[0]->getID(), boost::shared_ptr<RosterPayload>())); + channel_->onIQReceived(IQ::createResult(JID("baz@fum.com/dum"), channel_->sentStanzas[0]->getID(), std::shared_ptr<RosterPayload>())); } void testAdd() { XMPPRosterController controller(router_, xmppRoster_, rosterStorage_); - boost::shared_ptr<RosterPayload> payload(new RosterPayload()); + std::shared_ptr<RosterPayload> payload(new RosterPayload()); payload->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "eou", payload)); @@ -97,65 +97,65 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { } void testGet_NoRosterInStorage() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->setUseVersioning(true); testling->requestRoster(); - boost::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); + std::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); CPPUNIT_ASSERT(roster->getVersion()); CPPUNIT_ASSERT_EQUAL(std::string(""), *roster->getVersion()); } void testGet_NoVersionInStorage() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->setUseVersioning(true); - rosterStorage_->setRoster(boost::make_shared<RosterPayload>()); + rosterStorage_->setRoster(std::make_shared<RosterPayload>()); testling->requestRoster(); - boost::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); + std::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); CPPUNIT_ASSERT(roster->getVersion()); CPPUNIT_ASSERT_EQUAL(std::string(""), *roster->getVersion()); } void testGet_VersionInStorage() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->setUseVersioning(true); - boost::shared_ptr<RosterPayload> payload(new RosterPayload()); + std::shared_ptr<RosterPayload> payload(new RosterPayload()); payload->setVersion("foover"); rosterStorage_->setRoster(payload); testling->requestRoster(); - boost::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); + std::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); CPPUNIT_ASSERT(roster->getVersion()); CPPUNIT_ASSERT_EQUAL(std::string("foover"), *roster->getVersion()); } void testGet_ServerDoesNotSupportVersion() { - boost::shared_ptr<XMPPRosterController> testling(createController()); - boost::shared_ptr<RosterPayload> payload(new RosterPayload()); + std::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<RosterPayload> payload(new RosterPayload()); payload->setVersion("foover"); rosterStorage_->setRoster(payload); testling->requestRoster(); - boost::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); + std::shared_ptr<RosterPayload> roster = channel_->sentStanzas[0]->getPayload<RosterPayload>(); CPPUNIT_ASSERT(!roster->getVersion()); } void testGet_ResponseWithoutNewVersion() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->setUseVersioning(true); - boost::shared_ptr<RosterPayload> storedRoster(new RosterPayload()); + std::shared_ptr<RosterPayload> storedRoster(new RosterPayload()); storedRoster->setVersion("version10"); storedRoster->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); storedRoster->addItem(RosterItemPayload(jid2_, "Alice", RosterItemPayload::Both)); rosterStorage_->setRoster(storedRoster); testling->requestRoster(); - channel_->onIQReceived(IQ::createResult("foo@bar.com", channel_->sentStanzas[0]->getID(), boost::shared_ptr<RosterPayload>())); + channel_->onIQReceived(IQ::createResult("foo@bar.com", channel_->sentStanzas[0]->getID(), std::shared_ptr<RosterPayload>())); CPPUNIT_ASSERT_EQUAL(2, handler_->getEventCount()); CPPUNIT_ASSERT(xmppRoster_->getItem(jid1_)); @@ -170,15 +170,15 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { } void testGet_ResponseWithNewVersion() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->setUseVersioning(true); - boost::shared_ptr<RosterPayload> storedRoster(new RosterPayload()); + std::shared_ptr<RosterPayload> storedRoster(new RosterPayload()); storedRoster->setVersion("version10"); storedRoster->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); rosterStorage_->setRoster(storedRoster); testling->requestRoster(); - boost::shared_ptr<RosterPayload> serverRoster(new RosterPayload()); + std::shared_ptr<RosterPayload> serverRoster(new RosterPayload()); serverRoster->setVersion("version12"); serverRoster->addItem(RosterItemPayload(jid2_, "Alice", RosterItemPayload::Both)); std::vector<std::string> groups; @@ -204,9 +204,9 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { } void testAddFromNonAccount() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); - boost::shared_ptr<RosterPayload> payload(new RosterPayload()); + std::shared_ptr<RosterPayload> payload(new RosterPayload()); payload->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); IQ::ref request = IQ::createRequest(IQ::Set, JID(), "eou", payload); request->setFrom(jid2_); @@ -217,7 +217,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { void testModify() { XMPPRosterController controller(router_, xmppRoster_, rosterStorage_); - boost::shared_ptr<RosterPayload> payload1(new RosterPayload()); + std::shared_ptr<RosterPayload> payload1(new RosterPayload()); payload1->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id1", payload1)); @@ -225,7 +225,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); handler_->reset(); - boost::shared_ptr<RosterPayload> payload2(new RosterPayload()); + std::shared_ptr<RosterPayload> payload2(new RosterPayload()); payload2->addItem(RosterItemPayload(jid1_, "Bob2", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id2", payload2)); @@ -237,7 +237,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { void testRemove() { XMPPRosterController controller(router_, xmppRoster_, rosterStorage_); - boost::shared_ptr<RosterPayload> payload1(new RosterPayload()); + std::shared_ptr<RosterPayload> payload1(new RosterPayload()); payload1->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id1", payload1)); @@ -245,7 +245,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); handler_->reset(); - boost::shared_ptr<RosterPayload> payload2(new RosterPayload()); + std::shared_ptr<RosterPayload> payload2(new RosterPayload()); payload2->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Remove)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id2", payload2)); CPPUNIT_ASSERT(!xmppRoster_->containsJID(jid1_)); @@ -255,17 +255,17 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { } void testRemove_RosterStorageUpdated() { - boost::shared_ptr<XMPPRosterController> testling(createController()); + std::shared_ptr<XMPPRosterController> testling(createController()); testling->setUseVersioning(true); - boost::shared_ptr<RosterPayload> storedRoster(new RosterPayload()); + std::shared_ptr<RosterPayload> storedRoster(new RosterPayload()); storedRoster->setVersion("version10"); storedRoster->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); storedRoster->addItem(RosterItemPayload(jid2_, "Alice", RosterItemPayload::Both)); rosterStorage_->setRoster(storedRoster); testling->requestRoster(); - channel_->onIQReceived(IQ::createResult("foo@bar.com", channel_->sentStanzas[0]->getID(), boost::shared_ptr<RosterPayload>())); + channel_->onIQReceived(IQ::createResult("foo@bar.com", channel_->sentStanzas[0]->getID(), std::shared_ptr<RosterPayload>())); - boost::shared_ptr<RosterPayload> payload2(new RosterPayload()); + std::shared_ptr<RosterPayload> payload2(new RosterPayload()); payload2->setVersion("version15"); payload2->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Remove)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id2", payload2)); @@ -279,7 +279,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { void testMany() { XMPPRosterController controller(router_, xmppRoster_, rosterStorage_); - boost::shared_ptr<RosterPayload> payload1(new RosterPayload()); + std::shared_ptr<RosterPayload> payload1(new RosterPayload()); payload1->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id1", payload1)); @@ -287,7 +287,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); handler_->reset(); - boost::shared_ptr<RosterPayload> payload2(new RosterPayload()); + std::shared_ptr<RosterPayload> payload2(new RosterPayload()); payload2->addItem(RosterItemPayload(jid2_, "Alice", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id2", payload2)); @@ -295,7 +295,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID()); handler_->reset(); - boost::shared_ptr<RosterPayload> payload3(new RosterPayload()); + std::shared_ptr<RosterPayload> payload3(new RosterPayload()); payload3->addItem(RosterItemPayload(jid1_, "Ernie", RosterItemPayload::Both)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id3", payload3)); @@ -303,7 +303,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); handler_->reset(); - boost::shared_ptr<RosterPayload> payload4(new RosterPayload()); + std::shared_ptr<RosterPayload> payload4(new RosterPayload()); RosterItemPayload item(jid3_, "Jane", RosterItemPayload::Both); std::string janesGroup("Jane's Group"); item.addGroup(janesGroup); @@ -316,7 +316,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(janesGroup, xmppRoster_->getGroupsForJID(jid3_)[0]); handler_->reset(); - boost::shared_ptr<RosterPayload> payload5(new RosterPayload()); + std::shared_ptr<RosterPayload> payload5(new RosterPayload()); payload5->addItem(RosterItemPayload(jid1_, "Bob", RosterItemPayload::Remove)); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id5", payload5)); CPPUNIT_ASSERT(!xmppRoster_->containsJID(jid1_)); @@ -324,7 +324,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); handler_->reset(); - boost::shared_ptr<RosterPayload> payload6(new RosterPayload()); + std::shared_ptr<RosterPayload> payload6(new RosterPayload()); RosterItemPayload item2(jid2_, "Little Alice", RosterItemPayload::Both); std::string alicesGroup("Alice's Group"); item2.addGroup(alicesGroup); diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp index f611fec..f0d92e9 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp @@ -4,8 +4,9 @@ * See the COPYING file for more information. */ +#include <memory> + #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> diff --git a/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h b/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h index 9c9afad..0535578 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h +++ b/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h @@ -6,10 +6,9 @@ #pragma once +#include <memory> #include <vector> -#include <boost/shared_ptr.hpp> - #include <Swiften/Roster/XMPPRosterImpl.h> enum XMPPRosterEvents {None, Add, Remove, Update}; |