summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-29 15:22:52 (GMT)
committerTobias Markmann <tm@ayena.de>2016-09-29 15:22:52 (GMT)
commit9abfaaa771f91010dbe01a1b9b5b9e2801956718 (patch)
tree618a5f66ea97d3d8552f72aad6a8e1313c56ec6e /Swiften
parent2bf44a1d641c3bc35546cb49d3766f2962f9a984 (diff)
downloadswift-9abfaaa771f91010dbe01a1b9b5b9e2801956718.zip
swift-9abfaaa771f91010dbe01a1b9b5b9e2801956718.tar.bz2
Fix uninitialised class members
Initialised previously uninitialised class members. Changed some raw pointers to std::unique_ptr for clearer and automatically initialised code. Test-Information: Builds on macOS 10.12 and unit tests pass in ASAN-enabled build. Change-Id: I7900fe6131119c228ca92c79c0ee8125137f2e48
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp46
-rw-r--r--Swiften/Component/UnitTest/ComponentSessionTest.cpp2
-rw-r--r--Swiften/Disco/UnitTest/CapsManagerTest.cpp19
-rw-r--r--Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp16
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardEllipseElement.h2
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardFreehandPathElement.h2
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardOperation.h2
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardPolygonElement.h2
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardTextElement.h2
-rw-r--r--Swiften/Elements/Whiteboard/WhiteboardUpdateOperation.h2
-rw-r--r--Swiften/EventLoop/BoostASIOEventLoop.h2
-rw-r--r--Swiften/FileTransfer/SOCKS5BytestreamServerManager.h2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp24
-rw-r--r--Swiften/MUC/MUCImpl.cpp2
-rw-r--r--Swiften/MUC/MUCImpl.h10
-rw-r--r--Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp17
-rw-r--r--Swiften/QA/TLSTest/CertificateTest.cpp15
-rw-r--r--Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp17
-rw-r--r--Swiften/Queries/UnitTest/ResponderTest.cpp27
-rw-r--r--Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp13
-rw-r--r--Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp2
21 files changed, 100 insertions, 126 deletions
diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
index 288a5af..8aca98e 100644
--- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
+++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp
@@ -4,6 +4,7 @@
* See the COPYING file for more information.
*/
+#include <memory>
#include <string>
#include <boost/bind.hpp>
@@ -47,8 +48,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
public:
void setUp() {
- avatarProvider1 = new DummyAvatarProvider();
- avatarProvider2 = new DummyAvatarProvider();
+ avatarProvider1 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider());
+ avatarProvider2 = std::unique_ptr<DummyAvatarProvider>(new DummyAvatarProvider());
user1 = JID("user1@bar.com/bla");
user2 = JID("user2@foo.com/baz");
avatarHash1 = "ABCDEFG";
@@ -56,11 +57,6 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
avatarHash3 = "IDGH";
}
- void tearDown() {
- delete avatarProvider1;
- delete avatarProvider2;
- }
-
void testGetAvatarWithNoAvatarProviderReturnsEmpty() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
@@ -71,7 +67,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testGetAvatarWithSingleAvatarProvider() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider1->avatars[user1] = avatarHash1;
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
boost::optional<std::string> hash = testling->getAvatarHash(user1);
CPPUNIT_ASSERT(hash);
@@ -82,8 +78,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider2->avatars[user1] = avatarHash2;
- testling->addProvider(avatarProvider1);
- testling->addProvider(avatarProvider2);
+ testling->addProvider(avatarProvider1.get());
+ testling->addProvider(avatarProvider2.get());
boost::optional<std::string> hash = testling->getAvatarHash(user1);
CPPUNIT_ASSERT(hash);
@@ -93,8 +89,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testGetAvatarWithMultipleAvatarProviderAndFailingFirstProviderReturnsSecondAvatar() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider2->avatars[user1] = avatarHash2;
- testling->addProvider(avatarProvider1);
- testling->addProvider(avatarProvider2);
+ testling->addProvider(avatarProvider1.get());
+ testling->addProvider(avatarProvider2.get());
boost::optional<std::string> hash = testling->getAvatarHash(user1);
CPPUNIT_ASSERT(hash);
@@ -103,7 +99,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateTriggersChange() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
@@ -113,8 +109,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateWithoutChangeDoesNotTriggerChange() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
- testling->addProvider(avatarProvider2);
+ testling->addProvider(avatarProvider1.get());
+ testling->addProvider(avatarProvider2.get());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
changes.clear();
@@ -127,7 +123,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderSecondUpdateTriggersChange() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
changes.clear();
@@ -141,7 +137,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateWithAvatarDisappearingTriggersChange() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
changes.clear();
@@ -154,7 +150,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateAfterAvatarDisappearedTriggersChange() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider1->onAvatarChanged(user1);
avatarProvider1->avatars.clear();
@@ -170,7 +166,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateAfterGetDoesNotTriggerChange() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
avatarProvider1->avatars[user1] = avatarHash1;
testling->getAvatarHash(user1);
@@ -181,9 +177,9 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testRemoveProviderDisconnectsUpdates() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
- testling->addProvider(avatarProvider1);
- testling->addProvider(avatarProvider2);
- testling->removeProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
+ testling->addProvider(avatarProvider2.get());
+ testling->removeProvider(avatarProvider1.get());
avatarProvider1->avatars[user1] = avatarHash1;
avatarProvider2->avatars[user1] = avatarHash2;
avatarProvider1->onAvatarChanged(user1);
@@ -194,7 +190,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
void testProviderUpdateBareJIDAfterGetFullJID() {
std::shared_ptr<CombinedAvatarProvider> testling(createProvider());
avatarProvider1->useBare = true;
- testling->addProvider(avatarProvider1);
+ testling->addProvider(avatarProvider1.get());
avatarProvider1->avatars[user1.toBare()] = avatarHash1;
testling->getAvatarHash(user1);
@@ -366,8 +362,8 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture {
std::vector<JID> mucs_;
};
- DummyAvatarProvider* avatarProvider1;
- DummyAvatarProvider* avatarProvider2;
+ std::unique_ptr<DummyAvatarProvider> avatarProvider1;
+ std::unique_ptr<DummyAvatarProvider> avatarProvider2;
JID user1;
JID user2;
std::string avatarHash1;
diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp
index 63c89dc..48c6d8d 100644
--- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp
@@ -214,7 +214,7 @@ class ComponentSessionTest : public CppUnit::TestFixture {
};
std::shared_ptr<MockSessionStream> server;
- bool sessionFinishedReceived;
+ bool sessionFinishedReceived = false;
std::shared_ptr<Error> sessionFinishedError;
std::shared_ptr<CryptoProvider> crypto;
};
diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
index ca727c2..153e821 100644
--- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp
@@ -4,6 +4,7 @@
* See the COPYING file for more information.
*/
+#include <memory>
#include <vector>
#include <boost/bind.hpp>
@@ -46,9 +47,9 @@ class CapsManagerTest : public CppUnit::TestFixture {
public:
void setUp() {
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- stanzaChannel = new DummyStanzaChannel();
- iqRouter = new IQRouter(stanzaChannel);
- storage = new CapsMemoryStorage();
+ stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
+ iqRouter = std::unique_ptr<IQRouter>(new IQRouter(stanzaChannel.get()));
+ storage = std::unique_ptr<CapsMemoryStorage>(new CapsMemoryStorage());
user1 = JID("user1@bar.com/bla");
discoInfo1 = std::make_shared<DiscoInfo>();
discoInfo1->addFeature("http://swift.im/feature1");
@@ -63,9 +64,7 @@ class CapsManagerTest : public CppUnit::TestFixture {
}
void tearDown() {
- delete storage;
- delete iqRouter;
- delete stanzaChannel;
+ iqRouter.reset();
}
void testReceiveNewHashRequestsDisco() {
@@ -251,7 +250,7 @@ class CapsManagerTest : public CppUnit::TestFixture {
private:
std::shared_ptr<CapsManager> createManager() {
- std::shared_ptr<CapsManager> manager(new CapsManager(storage, stanzaChannel, iqRouter, crypto.get()));
+ std::shared_ptr<CapsManager> manager(new CapsManager(storage.get(), stanzaChannel.get(), iqRouter.get(), crypto.get()));
manager->setWarnOnInvalidHash(false);
//manager->onCapsChanged.connect(boost::bind(&CapsManagerTest::handleCapsChanged, this, _1));
return manager;
@@ -273,9 +272,9 @@ class CapsManagerTest : public CppUnit::TestFixture {
}
private:
- DummyStanzaChannel* stanzaChannel;
- IQRouter* iqRouter;
- CapsStorage* storage;
+ std::unique_ptr<DummyStanzaChannel> stanzaChannel;
+ std::unique_ptr<IQRouter> iqRouter;
+ std::unique_ptr<CapsStorage> storage;
std::vector<JID> changes;
JID user1;
std::shared_ptr<DiscoInfo> discoInfo1;
diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
index d775f6c..8c59741 100644
--- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
+++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp
@@ -4,6 +4,7 @@
* See the COPYING file for more information.
*/
+#include <memory>
#include <vector>
#include <boost/bind.hpp>
@@ -36,8 +37,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
void setUp() {
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
- stanzaChannel = new DummyStanzaChannel();
- capsProvider = new DummyCapsProvider();
+ stanzaChannel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
+ capsProvider = std::unique_ptr<DummyCapsProvider>(new DummyCapsProvider());
user1 = JID("user1@bar.com/bla");
discoInfo1 = std::make_shared<DiscoInfo>();
@@ -52,11 +53,6 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
legacyCapsInfo = std::make_shared<CapsInfo>("http://swift.im", "ver1", "");
}
- void tearDown() {
- delete capsProvider;
- delete stanzaChannel;
- }
-
void testReceiveKnownHash() {
std::shared_ptr<EntityCapsManager> testling = createManager();
capsProvider->caps[capsInfo1->getVersion()] = discoInfo1;
@@ -140,7 +136,7 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
private:
std::shared_ptr<EntityCapsManager> createManager() {
- std::shared_ptr<EntityCapsManager> manager(new EntityCapsManager(capsProvider, stanzaChannel));
+ std::shared_ptr<EntityCapsManager> manager(new EntityCapsManager(capsProvider.get(), stanzaChannel.get()));
manager->onCapsChanged.connect(boost::bind(&EntityCapsManagerTest::handleCapsChanged, this, _1));
return manager;
}
@@ -177,8 +173,8 @@ class EntityCapsManagerTest : public CppUnit::TestFixture {
};
private:
- DummyStanzaChannel* stanzaChannel;
- DummyCapsProvider* capsProvider;
+ std::unique_ptr<DummyStanzaChannel> stanzaChannel;
+ std::unique_ptr<DummyCapsProvider> capsProvider;
JID user1;
std::shared_ptr<DiscoInfo> discoInfo1;
std::shared_ptr<CapsInfo> capsInfo1;
diff --git a/Swiften/Elements/Whiteboard/WhiteboardEllipseElement.h b/Swiften/Elements/Whiteboard/WhiteboardEllipseElement.h
index 7d80bf7..8086aed 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardEllipseElement.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardEllipseElement.h
@@ -76,6 +76,6 @@ namespace Swift {
int cx_, cy_, rx_, ry_;
WhiteboardColor penColor_;
WhiteboardColor brushColor_;
- int penWidth_;
+ int penWidth_ = 0;
};
}
diff --git a/Swiften/Elements/Whiteboard/WhiteboardFreehandPathElement.h b/Swiften/Elements/Whiteboard/WhiteboardFreehandPathElement.h
index b8b7e54..bc6c846 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardFreehandPathElement.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardFreehandPathElement.h
@@ -59,6 +59,6 @@ namespace Swift {
private:
std::vector<Point> points_;
WhiteboardColor color_;
- int penWidth_;
+ int penWidth_ = 0;
};
}
diff --git a/Swiften/Elements/Whiteboard/WhiteboardOperation.h b/Swiften/Elements/Whiteboard/WhiteboardOperation.h
index 7d48e4d..2e90c69 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardOperation.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardOperation.h
@@ -54,6 +54,6 @@ namespace Swift {
private:
std::string id_;
std::string parentID_;
- int pos_;
+ int pos_ = 0;
};
}
diff --git a/Swiften/Elements/Whiteboard/WhiteboardPolygonElement.h b/Swiften/Elements/Whiteboard/WhiteboardPolygonElement.h
index b8591cf..6ad5dc7 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardPolygonElement.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardPolygonElement.h
@@ -67,6 +67,6 @@ namespace Swift {
std::vector<Point> points_;
WhiteboardColor penColor_;
WhiteboardColor brushColor_;
- int penWidth_;
+ int penWidth_ = 0;
};
}
diff --git a/Swiften/Elements/Whiteboard/WhiteboardTextElement.h b/Swiften/Elements/Whiteboard/WhiteboardTextElement.h
index 41f31f6..2e1c145 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardTextElement.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardTextElement.h
@@ -64,7 +64,7 @@ namespace Swift {
private:
int x_, y_;
- int size_;
+ int size_ = 0;
std::string text_;
WhiteboardColor color_;
};
diff --git a/Swiften/Elements/Whiteboard/WhiteboardUpdateOperation.h b/Swiften/Elements/Whiteboard/WhiteboardUpdateOperation.h
index b6dfd4f..36cbc6d 100644
--- a/Swiften/Elements/Whiteboard/WhiteboardUpdateOperation.h
+++ b/Swiften/Elements/Whiteboard/WhiteboardUpdateOperation.h
@@ -39,6 +39,6 @@ namespace Swift {
private:
WhiteboardElement::ref element_;
- int newPos_;
+ int newPos_ = 0;
};
}
diff --git a/Swiften/EventLoop/BoostASIOEventLoop.h b/Swiften/EventLoop/BoostASIOEventLoop.h
index 3f74a60..fbdf443 100644
--- a/Swiften/EventLoop/BoostASIOEventLoop.h
+++ b/Swiften/EventLoop/BoostASIOEventLoop.h
@@ -29,7 +29,7 @@ namespace Swift {
private:
std::shared_ptr<boost::asio::io_service> ioService_;
- bool isEventInASIOEventLoop_;
+ bool isEventInASIOEventLoop_ = false;
std::recursive_mutex isEventInASIOEventLoopMutex_;
};
}
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
index 6dbdd1b..3c06513 100644
--- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
+++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h
@@ -78,7 +78,7 @@ namespace Swift {
enum { Start, Initializing, Initialized } state;
SOCKS5BytestreamServer* server;
std::shared_ptr<ConnectionServer> connectionServer;
- int connectionServerPort;
+ int connectionServerPort = -1;
std::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest;
std::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest;
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index b241320..cb43d78 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -59,9 +59,9 @@ public:
crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
destination = "092a44d859d19c9eed676b551ee80025903351c2";
randomGen.seed(static_cast<unsigned int>(time(nullptr)));
- eventLoop = new DummyEventLoop();
- timerFactory = new DummyTimerFactory();
- connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop);
+ eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop());
+ timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory());
+ connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get());
//connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
//stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")));
// connection->onDataRead.connect(boost::bind(&SOCKS5BytestreamClientSessionTest::handleDataRead, this, _1));
@@ -69,15 +69,13 @@ public:
void tearDown() {
//connection.reset();
- delete timerFactory;
- delete eventLoop;
}
void testForSessionReady() {
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -103,7 +101,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -123,7 +121,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -150,7 +148,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -178,7 +176,7 @@ public:
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
- SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
+ SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get());
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
@@ -203,8 +201,6 @@ public:
CPPUNIT_ASSERT_EQUAL(createByteArray(vecptr(transferData), transferData.size()), helper.unprocessedInput);
}
-
-
private:
static ByteArray generateRandomByteArray(size_t len) {
boost::uniform_int<> dist(0, 255);
@@ -308,8 +304,8 @@ private:
private:
HostAddressPort destinationAddressPort;
std::string destination;
- DummyEventLoop* eventLoop;
- DummyTimerFactory* timerFactory;
+ std::unique_ptr<DummyEventLoop> eventLoop;
+ std::unique_ptr<DummyTimerFactory> timerFactory;
std::shared_ptr<MockeryConnection> connection;
const std::vector<HostAddressPort> failingPorts;
std::shared_ptr<CryptoProvider> crypto;
diff --git a/Swiften/MUC/MUCImpl.cpp b/Swiften/MUC/MUCImpl.cpp
index ba8d03e..029bb4b 100644
--- a/Swiften/MUC/MUCImpl.cpp
+++ b/Swiften/MUC/MUCImpl.cpp
@@ -29,7 +29,7 @@ namespace Swift {
typedef std::pair<std::string, MUCOccupant> StringMUCOccupantPair;
-MUCImpl::MUCImpl(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSender* presenceSender, const JID &muc, MUCRegistry* mucRegistry) : ownMUCJID(muc), stanzaChannel(stanzaChannel), iqRouter_(iqRouter), presenceSender(presenceSender), mucRegistry(mucRegistry), createAsReservedIfNew(false), unlocking(false), isUnlocked_(false) {
+MUCImpl::MUCImpl(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSender* presenceSender, const JID &muc, MUCRegistry* mucRegistry) : ownMUCJID(muc), stanzaChannel(stanzaChannel), iqRouter_(iqRouter), presenceSender(presenceSender), mucRegistry(mucRegistry) {
scopedConnection_ = stanzaChannel->onPresenceReceived.connect(boost::bind(&MUCImpl::handleIncomingPresence, this, _1));
}
diff --git a/Swiften/MUC/MUCImpl.h b/Swiften/MUC/MUCImpl.h
index 5009bc2..1c02dee 100644
--- a/Swiften/MUC/MUCImpl.h
+++ b/Swiften/MUC/MUCImpl.h
@@ -117,13 +117,13 @@ namespace Swift {
DirectedPresenceSender* presenceSender;
MUCRegistry* mucRegistry;
std::map<std::string, MUCOccupant> occupants;
- bool joinSucceeded_;
- bool joinComplete_;
+ bool joinSucceeded_ = false;
+ bool joinComplete_ = false;
boost::signals2::scoped_connection scopedConnection_;
boost::posix_time::ptime joinSince_;
- bool createAsReservedIfNew;
- bool unlocking;
- bool isUnlocked_;
+ bool createAsReservedIfNew = false;
+ bool unlocking = false;
+ bool isUnlocked_ = false;
boost::optional<std::string> password;
Presence::ref joinRequestPresence_;
};
diff --git a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
index 2ce67dc..38e67fb 100644
--- a/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
+++ b/Swiften/Presence/UnitTest/DirectedPresenceSenderTest.cpp
@@ -4,6 +4,8 @@
* See the COPYING file for more information.
*/
+#include <memory>
+
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
@@ -27,17 +29,12 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture {
public:
void setUp() {
- channel = new DummyStanzaChannel();
+ channel = std::unique_ptr<DummyStanzaChannel>(new DummyStanzaChannel());
testPresence = std::make_shared<Presence>();
testPresence->setStatus("Foo");
secondTestPresence = std::make_shared<Presence>();
secondTestPresence->setStatus("Bar");
- stanzaChannelPresenceSender = new StanzaChannelPresenceSender(channel);
- }
-
- void tearDown() {
- delete stanzaChannelPresenceSender;
- delete channel;
+ stanzaChannelPresenceSender = std::unique_ptr<StanzaChannelPresenceSender>(new StanzaChannelPresenceSender(channel.get()));
}
void testSendPresence() {
@@ -140,12 +137,12 @@ class DirectedPresenceSenderTest : public CppUnit::TestFixture {
private:
DirectedPresenceSender* createPresenceSender() {
- return new DirectedPresenceSender(stanzaChannelPresenceSender);
+ return new DirectedPresenceSender(stanzaChannelPresenceSender.get());
}
private:
- DummyStanzaChannel* channel;
- StanzaChannelPresenceSender* stanzaChannelPresenceSender;
+ std::unique_ptr<DummyStanzaChannel> channel;
+ std::unique_ptr<StanzaChannelPresenceSender> stanzaChannelPresenceSender;
std::shared_ptr<Presence> testPresence;
std::shared_ptr<Presence> secondTestPresence;
};
diff --git a/Swiften/QA/TLSTest/CertificateTest.cpp b/Swiften/QA/TLSTest/CertificateTest.cpp
index ede1063..b53cd2f 100644
--- a/Swiften/QA/TLSTest/CertificateTest.cpp
+++ b/Swiften/QA/TLSTest/CertificateTest.cpp
@@ -4,6 +4,8 @@
* See the COPYING file for more information.
*/
+#include <memory>
+
#include <boost/bind.hpp>
#include <QA/Checker/IO.h>
@@ -32,14 +34,9 @@ class CertificateTest : public CppUnit::TestFixture {
public:
void setUp() {
- pathProvider = new PlatformApplicationPathProvider("FileReadBytestreamTest");
+ pathProvider = std::unique_ptr<PlatformApplicationPathProvider>(new PlatformApplicationPathProvider("FileReadBytestreamTest"));
readByteArrayFromFile(certificateData, (pathProvider->getExecutableDir() / "jabber_org.crt"));
- certificateFactory = new CERTIFICATE_FACTORY();
- }
-
- void tearDown() {
- delete certificateFactory;
- delete pathProvider;
+ certificateFactory = std::unique_ptr<CertificateFactory>(new CERTIFICATE_FACTORY());
}
void testConstructFromDER() {
@@ -92,9 +89,9 @@ class CertificateTest : public CppUnit::TestFixture {
}
private:
- PlatformApplicationPathProvider* pathProvider;
+ std::unique_ptr<PlatformApplicationPathProvider> pathProvider;
ByteArray certificateData;
- CertificateFactory* certificateFactory;
+ std::unique_ptr<CertificateFactory> certificateFactory;
};
#ifdef HAVE_OPENSSL
diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp
index 6c4c495..8a4b9fc 100644
--- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp
+++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp
@@ -34,17 +34,16 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture {
public:
void setUp() {
- channel = new DummyIQChannel();
- router = new IQRouter(channel);
+ channel = std::unique_ptr<DummyIQChannel>(new DummyIQChannel());
+ router = std::unique_ptr<IQRouter>(new IQRouter(channel.get()));
}
void tearDown() {
- delete router;
- delete channel;
+ router.reset();
}
void testSend() {
- GetPrivateStorageRequest<MyPayload>::ref request = GetPrivateStorageRequest<MyPayload>::create(router);
+ GetPrivateStorageRequest<MyPayload>::ref request = GetPrivateStorageRequest<MyPayload>::create(router.get());
request->send();
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel->iqs_.size()));
@@ -57,7 +56,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture {
}
void testHandleResponse() {
- GetPrivateStorageRequest<MyPayload>::ref testling = GetPrivateStorageRequest<MyPayload>::create(router);
+ GetPrivateStorageRequest<MyPayload>::ref testling = GetPrivateStorageRequest<MyPayload>::create(router.get());
testling->onResponse.connect(boost::bind(&GetPrivateStorageRequestTest::handleResponse, this, _1, _2));
testling->send();
channel->onIQReceived(createResponse("test-id", "foo"));
@@ -67,7 +66,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture {
}
void testHandleResponse_Error() {
- GetPrivateStorageRequest<MyPayload>::ref testling = GetPrivateStorageRequest<MyPayload>::create(router);
+ GetPrivateStorageRequest<MyPayload>::ref testling = GetPrivateStorageRequest<MyPayload>::create(router.get());
testling->onResponse.connect(boost::bind(&GetPrivateStorageRequestTest::handleResponse, this, _1, _2));
testling->send();
channel->onIQReceived(createError("test-id"));
@@ -102,8 +101,8 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture {
}
private:
- IQRouter* router;
- DummyIQChannel* channel;
+ std::unique_ptr<IQRouter> router;
+ std::unique_ptr<DummyIQChannel> channel;
std::vector< ErrorPayload > errors;
std::vector< std::shared_ptr<Payload> > responses;
};
diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp
index 98c1448..94bfed1 100644
--- a/Swiften/Queries/UnitTest/ResponderTest.cpp
+++ b/Swiften/Queries/UnitTest/ResponderTest.cpp
@@ -32,18 +32,17 @@ class ResponderTest : public CppUnit::TestFixture {
public:
void setUp() {
- channel_ = new DummyIQChannel();
- router_ = new IQRouter(channel_);
+ channel_ = std::unique_ptr<DummyIQChannel>(new DummyIQChannel());
+ router_ = std::unique_ptr<IQRouter>(new IQRouter(channel_.get()));
payload_ = std::make_shared<SoftwareVersion>("foo");
}
void tearDown() {
- delete router_;
- delete channel_;
+ router_.reset();
}
void testConstructor() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
channel_->onIQReceived(createRequest(IQ::Set));
@@ -51,7 +50,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testStart() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
testling.start();
channel_->onIQReceived(createRequest(IQ::Set));
@@ -60,7 +59,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testStop() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
testling.start();
testling.stop();
@@ -70,7 +69,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testHandleIQ_Set() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
CPPUNIT_ASSERT(dynamic_cast<IQHandler*>(&testling)->handleIQ(createRequest(IQ::Set)));
@@ -80,7 +79,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testHandleIQ_Get() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
CPPUNIT_ASSERT(dynamic_cast<IQHandler*>(&testling)->handleIQ(createRequest(IQ::Get)));
@@ -90,7 +89,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testHandleIQ_Error() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(createRequest(IQ::Error)));
@@ -99,7 +98,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testHandleIQ_Result() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(createRequest(IQ::Result)));
@@ -108,7 +107,7 @@ class ResponderTest : public CppUnit::TestFixture {
}
void testHandleIQ_NoPayload() {
- MyResponder testling(router_);
+ MyResponder testling(router_.get());
CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(std::make_shared<IQ>(IQ::Get)));
@@ -150,8 +149,8 @@ class ResponderTest : public CppUnit::TestFixture {
};
private:
- IQRouter* router_;
- DummyIQChannel* channel_;
+ std::unique_ptr<IQRouter> router_;
+ std::unique_ptr<DummyIQChannel> channel_;
std::shared_ptr<SoftwareVersion> payload_;
};
diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp
index f0d92e9..73e76d3 100644
--- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp
+++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp
@@ -30,18 +30,13 @@ class XMPPRosterImplTest : public CppUnit::TestFixture {
jid1_ = JID("a@b.c");
jid2_ = JID("b@c.d");
jid3_ = JID("c@d.e");
- roster_ = new XMPPRosterImpl();
- handler_ = new XMPPRosterSignalHandler(roster_);
+ roster_ = std::unique_ptr<XMPPRosterImpl>(new XMPPRosterImpl());
+ handler_ = std::unique_ptr<XMPPRosterSignalHandler>(new XMPPRosterSignalHandler(roster_.get()));
groups1_.push_back("bobs");
groups1_.push_back("berts");
groups2_.push_back("ernies");
}
- void tearDown() {
- delete handler_;
- delete roster_;
- }
-
void testJIDAdded() {
roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both);
CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
@@ -101,8 +96,8 @@ class XMPPRosterImplTest : public CppUnit::TestFixture {
}
private:
- XMPPRosterImpl* roster_;
- XMPPRosterSignalHandler* handler_;
+ std::unique_ptr<XMPPRosterImpl> roster_;
+ std::unique_ptr<XMPPRosterSignalHandler> handler_;
JID jid1_;
JID jid2_;
JID jid3_;
diff --git a/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp b/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp
index b1bc7c2..ce16e1f 100644
--- a/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp
+++ b/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp
@@ -157,7 +157,7 @@ class StanzaAckRequesterTest : public CppUnit::TestFixture {
}
private:
- int acksRequested;
+ int acksRequested = 0;
std::vector< std::shared_ptr<Stanza> > ackedStanzas;
};