diff options
author | Tobias Markmann <tm@ayena.de> | 2016-09-29 15:22:52 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-09-29 15:22:52 (GMT) |
commit | 9abfaaa771f91010dbe01a1b9b5b9e2801956718 (patch) | |
tree | 618a5f66ea97d3d8552f72aad6a8e1313c56ec6e /Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp | |
parent | 2bf44a1d641c3bc35546cb49d3766f2962f9a984 (diff) | |
download | swift-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/Disco/UnitTest/EntityCapsManagerTest.cpp')
-rw-r--r-- | Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
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; |