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 /Swift/Controllers/Roster/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 'Swift/Controllers/Roster/UnitTest')
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterTest.cpp8
-rw-r--r--Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp18
2 files changed, 9 insertions, 17 deletions
diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
index 4687176..5f500d4 100644
--- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
@@ -30,11 +30,7 @@ class RosterTest : public CppUnit::TestFixture {
jid1_ = JID("a@b.c");
jid2_ = JID("b@c.d");
jid3_ = JID("c@d.e");
- roster_ = new Roster();
- }
-
- void tearDown() {
- delete roster_;
+ roster_ = std::unique_ptr<Roster>(new Roster());
}
void testGetGroup() {
@@ -136,7 +132,7 @@ class RosterTest : public CppUnit::TestFixture {
}
private:
- Roster *roster_;
+ std::unique_ptr<Roster> roster_;
JID jid1_;
JID jid2_;
JID jid3_;
diff --git a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp
index e4e8bdb..ddc8785 100644
--- a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp
@@ -13,10 +13,11 @@ std::ostream& operator<<(std::ostream& os, const Swift::TableRoster::Index& i) {
return os;
}
+#include <memory>
+
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <memory>
#include <boost/variant.hpp>
#include <Swiften/Network/DummyTimerFactory.h>
@@ -33,17 +34,12 @@ class TableRosterTest : public CppUnit::TestFixture {
public:
void setUp() {
- timerFactory = new DummyTimerFactory();
- roster = new Roster();
+ timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory());
+ roster = std::unique_ptr<Roster>(new Roster());
jid1 = JID("jid1@example.com");
jid2 = JID("jid2@example.com");
}
- void tearDown() {
- delete roster;
- delete timerFactory;
- }
-
void testAddContact_EmptyRoster() {
/*
std::shared_ptr<TableRoster> tableRoster(createTestling());
@@ -73,7 +69,7 @@ class TableRosterTest : public CppUnit::TestFixture {
}
TableRoster* createTestling() {
- TableRoster* result = new TableRoster(roster, timerFactory, 10);
+ TableRoster* result = new TableRoster(roster.get(), timerFactory.get(), 10);
result->onUpdate.connect(boost::bind(&TableRosterTest::handleUpdate, this, _1));
return result;
}
@@ -83,8 +79,8 @@ class TableRosterTest : public CppUnit::TestFixture {
}
private:
- DummyTimerFactory* timerFactory;
- Roster* roster;
+ std::unique_ptr<DummyTimerFactory> timerFactory;
+ std::unique_ptr<Roster> roster;
JID jid1;
JID jid2;
std::vector<TableRoster::Update> updates;