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/Component/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/Component/UnitTest')
-rw-r--r--Swiften/Component/UnitTest/ComponentConnectorTest.cpp12
-rw-r--r--Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp6
-rw-r--r--Swiften/Component/UnitTest/ComponentSessionTest.cpp38
3 files changed, 28 insertions, 28 deletions
diff --git a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
index 04a6a9e..3515a0a 100644
--- a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2015 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -152,8 +152,8 @@ class ComponentConnectorTest : public CppUnit::TestFixture {
return connector;
}
- void handleConnectorFinished(boost::shared_ptr<Connection> connection) {
- boost::shared_ptr<MockConnection> c(boost::dynamic_pointer_cast<MockConnection>(connection));
+ void handleConnectorFinished(std::shared_ptr<Connection> connection) {
+ std::shared_ptr<MockConnection> c(std::dynamic_pointer_cast<MockConnection>(connection));
if (connection) {
assert(c);
}
@@ -188,8 +188,8 @@ class ComponentConnectorTest : public CppUnit::TestFixture {
MockConnectionFactory(EventLoop* eventLoop) : eventLoop(eventLoop), isResponsive(true) {
}
- boost::shared_ptr<Connection> createConnection() {
- return boost::shared_ptr<Connection>(new MockConnection(failingPorts, isResponsive, eventLoop));
+ std::shared_ptr<Connection> createConnection() {
+ return std::make_shared<MockConnection>(failingPorts, isResponsive, eventLoop);
}
EventLoop* eventLoop;
@@ -204,7 +204,7 @@ class ComponentConnectorTest : public CppUnit::TestFixture {
StaticDomainNameResolver* resolver;
MockConnectionFactory* connectionFactory;
DummyTimerFactory* timerFactory;
- std::vector< boost::shared_ptr<MockConnection> > connections;
+ std::vector< std::shared_ptr<MockConnection> > connections;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ComponentConnectorTest);
diff --git a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp
index 82f43f6..ce8eaa4 100644
--- a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -21,7 +21,7 @@ class ComponentHandshakeGeneratorTest : public CppUnit::TestFixture {
public:
void setUp() {
- crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
+ crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
}
void testGetHandshake() {
@@ -35,7 +35,7 @@ class ComponentHandshakeGeneratorTest : public CppUnit::TestFixture {
}
private:
- boost::shared_ptr<CryptoProvider> crypto;
+ std::shared_ptr<CryptoProvider> crypto;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ComponentHandshakeGeneratorTest);
diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp
index 1726794..63c89dc 100644
--- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp
@@ -30,13 +30,13 @@ class ComponentSessionTest : public CppUnit::TestFixture {
public:
void setUp() {
- server = boost::make_shared<MockSessionStream>();
+ server = std::make_shared<MockSessionStream>();
sessionFinishedReceived = false;
- crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
+ crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
}
void testStart() {
- boost::shared_ptr<ComponentSession> session(createSession());
+ std::shared_ptr<ComponentSession> session(createSession());
session->start();
server->receiveStreamStart();
server->sendStreamStart();
@@ -51,7 +51,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
}
void testStart_Error() {
- boost::shared_ptr<ComponentSession> session(createSession());
+ std::shared_ptr<ComponentSession> session(createSession());
session->start();
server->breakConnection();
@@ -61,7 +61,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
}
void testStart_Unauthorized() {
- boost::shared_ptr<ComponentSession> session(createSession());
+ std::shared_ptr<ComponentSession> session(createSession());
session->start();
server->receiveStreamStart();
server->sendStreamStart();
@@ -74,13 +74,13 @@ class ComponentSessionTest : public CppUnit::TestFixture {
}
private:
- boost::shared_ptr<ComponentSession> createSession() {
- boost::shared_ptr<ComponentSession> session = ComponentSession::create(JID("service.foo.com"), "servicesecret", server, crypto.get());
+ std::shared_ptr<ComponentSession> createSession() {
+ std::shared_ptr<ComponentSession> session = ComponentSession::create(JID("service.foo.com"), "servicesecret", server, crypto.get());
session->onFinished.connect(boost::bind(&ComponentSessionTest::handleSessionFinished, this, _1));
return session;
}
- void handleSessionFinished(boost::shared_ptr<Error> error) {
+ void handleSessionFinished(std::shared_ptr<Error> error) {
sessionFinishedReceived = true;
sessionFinishedError = error;
}
@@ -88,11 +88,11 @@ class ComponentSessionTest : public CppUnit::TestFixture {
class MockSessionStream : public SessionStream {
public:
struct Event {
- Event(boost::shared_ptr<ToplevelElement> element) : element(element), footer(false) {}
+ Event(std::shared_ptr<ToplevelElement> element) : element(element), footer(false) {}
Event(const ProtocolHeader& header) : header(header), footer(false) {}
Event() : footer(true) {}
- boost::shared_ptr<ToplevelElement> element;
+ std::shared_ptr<ToplevelElement> element;
boost::optional<ProtocolHeader> header;
bool footer;
};
@@ -101,7 +101,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
}
virtual void close() {
- onClosed(boost::shared_ptr<Error>());
+ onClosed(std::shared_ptr<Error>());
}
virtual bool isOpen() {
@@ -116,7 +116,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
receivedEvents.push_back(Event());
}
- virtual void writeElement(boost::shared_ptr<ToplevelElement> element) {
+ virtual void writeElement(std::shared_ptr<ToplevelElement> element) {
receivedEvents.push_back(Event(element));
}
@@ -147,8 +147,8 @@ class ComponentSessionTest : public CppUnit::TestFixture {
return std::vector<Certificate::ref>();
}
- virtual boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const {
- return boost::shared_ptr<CertificateVerificationError>();
+ virtual std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const {
+ return std::shared_ptr<CertificateVerificationError>();
}
virtual bool supportsZLibCompression() {
@@ -168,7 +168,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
}
void breakConnection() {
- onClosed(boost::make_shared<SessionStream::SessionStreamError>(SessionStream::SessionStreamError::ConnectionReadError));
+ onClosed(std::make_shared<SessionStream::SessionStreamError>(SessionStream::SessionStreamError::ConnectionReadError));
}
void sendStreamStart() {
@@ -194,7 +194,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
void receiveHandshake() {
Event event = popEvent();
CPPUNIT_ASSERT(event.element);
- ComponentHandshake::ref handshake(boost::dynamic_pointer_cast<ComponentHandshake>(event.element));
+ ComponentHandshake::ref handshake(std::dynamic_pointer_cast<ComponentHandshake>(event.element));
CPPUNIT_ASSERT(handshake);
CPPUNIT_ASSERT_EQUAL(std::string("4c4f8a41141722c8bbfbdd92d827f7b2fc0a542b"), handshake->getData());
}
@@ -213,10 +213,10 @@ class ComponentSessionTest : public CppUnit::TestFixture {
std::deque<Event> receivedEvents;
};
- boost::shared_ptr<MockSessionStream> server;
+ std::shared_ptr<MockSessionStream> server;
bool sessionFinishedReceived;
- boost::shared_ptr<Error> sessionFinishedError;
- boost::shared_ptr<CryptoProvider> crypto;
+ std::shared_ptr<Error> sessionFinishedError;
+ std::shared_ptr<CryptoProvider> crypto;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ComponentSessionTest);