diff options
Diffstat (limited to 'Swift/Controllers/Roster')
-rw-r--r-- | Swift/Controllers/Roster/UnitTest/RosterTest.cpp | 8 | ||||
-rw-r--r-- | Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp | 18 |
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; |