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/Avatars/UnitTest
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/Avatars/UnitTest')
-rw-r--r--Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp46
1 files changed, 21 insertions, 25 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;