summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Sluift/SluiftClient.h4
-rw-r--r--Sluift/SluiftComponent.h2
-rw-r--r--SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp15
-rw-r--r--Swift/Controllers/Chat/ChatController.h2
-rw-r--r--Swift/Controllers/HistoryViewController.h2
-rw-r--r--Swift/Controllers/MainController.h2
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterTest.cpp8
-rw-r--r--Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp18
-rw-r--r--Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp24
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h14
-rw-r--r--Swift/QtUI/QtHighlightEditor.h2
-rw-r--r--Swift/QtUI/QtLoginWindow.h2
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp4
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h8
-rw-r--r--Swift/QtUI/Trellis/QtDNDTabBar.h4
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.h1
-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
37 files changed, 146 insertions, 192 deletions
diff --git a/Sluift/SluiftClient.h b/Sluift/SluiftClient.h
index 1b0dd43..2c221e6 100644
--- a/Sluift/SluiftClient.h
+++ b/Sluift/SluiftClient.h
@@ -123,10 +123,10 @@ namespace Swift {
Client* client;
ClientOptions options;
ClientXMLTracer* tracer;
- bool rosterReceived;
+ bool rosterReceived = false;
std::deque<Event> pendingEvents;
boost::optional<ClientError> disconnectedError;
- bool requestResponseReceived;
+ bool requestResponseReceived = false;
std::shared_ptr<Payload> requestResponse;
std::shared_ptr<ErrorPayload> requestError;
};
diff --git a/Sluift/SluiftComponent.h b/Sluift/SluiftComponent.h
index 675d6c0..d45c3b2 100644
--- a/Sluift/SluiftComponent.h
+++ b/Sluift/SluiftComponent.h
@@ -102,7 +102,7 @@ namespace Swift {
ComponentXMLTracer* tracer;
std::deque<Event> pendingEvents;
boost::optional<ComponentError> disconnectedError;
- bool requestResponseReceived;
+ bool requestResponseReceived = false;
std::shared_ptr<Payload> requestResponse;
std::shared_ptr<ErrorPayload> requestError;
};
diff --git a/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp b/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
index fa9b184..ecd72b1 100644
--- a/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
+++ b/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
@@ -30,16 +30,11 @@ class ActualIdleDetectorTest : public CppUnit::TestFixture {
public:
void setUp() {
- querier = new MockIdleQuerier();
- timerFactory = new MockTimerFactory();
+ querier = std::unique_ptr<MockIdleQuerier>(new MockIdleQuerier());
+ timerFactory = std::unique_ptr<MockTimerFactory>(new MockTimerFactory());
idleEvents.clear();
}
- void tearDown() {
- delete timerFactory;
- delete querier;
- }
-
void testDestructor() {
ActualIdleDetector* testling = createDetector();
testling->setIdleTimeSeconds(15);
@@ -101,7 +96,7 @@ class ActualIdleDetectorTest : public CppUnit::TestFixture {
private:
ActualIdleDetector* createDetector() {
- ActualIdleDetector* detector = new ActualIdleDetector(querier, timerFactory, 10);
+ ActualIdleDetector* detector = new ActualIdleDetector(querier.get(), timerFactory.get(), 10);
detector->onIdleChanged.connect(boost::bind(&ActualIdleDetectorTest::handleIdle, this, _1));
return detector;
}
@@ -165,8 +160,8 @@ class ActualIdleDetectorTest : public CppUnit::TestFixture {
std::vector<std::shared_ptr<MockTimer> > timers;
};
- MockIdleQuerier* querier;
- MockTimerFactory* timerFactory;
+ std::unique_ptr<MockIdleQuerier> querier;
+ std::unique_ptr<MockTimerFactory> timerFactory;
std::vector<bool> idleEvents;
};
diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h
index 99f8e23..7bd6107 100644
--- a/Swift/Controllers/Chat/ChatController.h
+++ b/Swift/Controllers/Chat/ChatController.h
@@ -98,7 +98,7 @@ namespace Swift {
UIEventStream* eventStream_;
Tristate contactSupportsReceipts_;
- bool receivingPresenceFromUs_;
+ bool receivingPresenceFromUs_ = false;
bool userWantsReceipts_;
std::map<std::string, FileTransferController*> ftControllers;
SettingsProvider* settings_;
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index 4c4d9f9..75fc460 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -69,7 +69,7 @@ namespace Swift {
std::map<HistoryMessage::Type, ContactsMap> contacts_;
ContactRosterItem* selectedItem_;
- HistoryMessage::Type selectedItemType_;
+ HistoryMessage::Type selectedItemType_ = HistoryMessage::Chat;
boost::gregorian::date currentResultDate_;
};
}
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 4f691ee..cc3d45f 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -187,7 +187,7 @@ namespace Swift {
int timeBeforeNextReconnect_;
Timer::ref reconnectTimer_;
StatusTracker* statusTracker_;
- bool myStatusLooksOnline_;
+ bool myStatusLooksOnline_ = false;
bool quitRequested_;
bool offlineRequested_;
static const int SecondsToWaitBeforeForceQuitting;
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;
diff --git a/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp b/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp
index 5822add..3cfebc7 100644
--- a/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp
+++ b/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp
@@ -4,6 +4,8 @@
* See the COPYING file for more information.
*/
+#include <memory>
+
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
@@ -29,17 +31,11 @@ public:
SettingsProviderHierachyTest() : setting1("somekey", 42) {}
void setUp() {
- bottom = new DummySettingsProvider();
- top = new DummySettingsProvider();
- testling = new SettingsProviderHierachy();
- testling->addProviderToTopOfStack(bottom);
- testling->addProviderToTopOfStack(top);
- }
-
- void tearDown() {
- delete testling;
- delete top;
- delete bottom;
+ bottom = std::unique_ptr<DummySettingsProvider>(new DummySettingsProvider());
+ top = std::unique_ptr<DummySettingsProvider>(new DummySettingsProvider());
+ testling = std::unique_ptr<SettingsProviderHierachy>(new SettingsProviderHierachy());
+ testling->addProviderToTopOfStack(bottom.get());
+ testling->addProviderToTopOfStack(top.get());
}
void testEmpty() {
@@ -82,9 +78,9 @@ public:
CPPUNIT_ASSERT_EQUAL(17, testling->getSetting(setting1));
}
private:
- SettingsProviderHierachy* testling;
- DummySettingsProvider* bottom;
- DummySettingsProvider* top;
+ std::unique_ptr<SettingsProviderHierachy> testling;
+ std::unique_ptr<DummySettingsProvider> bottom;
+ std::unique_ptr<DummySettingsProvider> top;
SettingsProvider::Setting<int> setting1;
};
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index 054cd31..9b943f0 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -14,7 +14,7 @@
namespace Swift {
class MockChatWindow : public ChatWindow {
public:
- MockChatWindow() : labelsEnabled_(false), impromptuMUCSupported_(false) {}
+ MockChatWindow() {}
virtual ~MockChatWindow();
virtual std::string addMessage(const ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
@@ -128,21 +128,21 @@ namespace Swift {
std::string name_;
ChatMessage lastAddedMessage_;
std::string lastAddedMessageSenderName_;
- bool lastAddedMessageSenderIsSelf_;
+ bool lastAddedMessageSenderIsSelf_ = false;
ChatMessage lastAddedAction_;
std::string lastAddedActionSenderName_;
- bool lastAddedActionSenderIsSelf_;
+ bool lastAddedActionSenderIsSelf_ = false;
ChatMessage lastAddedPresence_;
ChatMessage lastReplacedMessage_;
ChatMessage lastAddedSystemMessage_;
ChatMessage lastReplacedSystemMessage_;
- ChatMessage lastAddedErrorMessage_;
+ ChatMessage lastAddedErrorMessage_;
JID lastMUCInvitationJID_;
std::vector<SecurityLabelsCatalog::Item> labels_;
- bool labelsEnabled_;
- bool impromptuMUCSupported_;
+ bool labelsEnabled_ = false;
+ bool impromptuMUCSupported_ = false;
SecurityLabelsCatalog::Item label_;
- Roster* roster_;
+ Roster* roster_ = nullptr;
std::vector<std::pair<std::string, ReceiptState>> receiptChanges_;
};
}
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index dbcef4b..c4a12e2 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -68,7 +68,7 @@ namespace Swift {
private:
Ui::QtHighlightEditor ui_;
QtSettingsProvider* settings_;
- HighlightManager* highlightManager_;
+ HighlightManager* highlightManager_ = nullptr;
QtSuggestingJIDInput* jid_;
int previousRow_;
};
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 91b21f6..c42d65d 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -98,7 +98,7 @@ namespace Swift {
QMenuBar* menuBar_;
QMenu* swiftMenu_;
QMenu* generalMenu_;
- QMenu* viewMenu_;
+ QMenu* viewMenu_ = nullptr;
QAction* toggleSoundsAction_;
QAction* toggleNotificationsAction_;
UIEventStream* uiEventStream_;
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index f04575d..1264a09 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -33,9 +33,7 @@
namespace Swift {
-QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), tooltipShown_(false), messageTarget_(messageTarget) {
- eventStream_ = eventStream;
- settings_ = settings;
+QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), eventStream_(eventStream), settings_(settings), messageTarget_(messageTarget) {
model_ = new RosterModel(this, settings_->getSetting(QtUISettingConstants::USE_SCREENREADER));
setModel(model_);
delegate_ = new RosterDelegate(this, settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER));
diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h
index b22f6bb..331458a 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.h
+++ b/Swift/QtUI/Roster/QtTreeWidget.h
@@ -68,13 +68,13 @@ class QtTreeWidget : public QTreeView {
private:
RosterModel* model_;
- Roster* roster_;
+ Roster* roster_ = nullptr;
RosterDelegate* delegate_;
- QtTreeWidgetItem* treeRoot_;
+ QtTreeWidgetItem* treeRoot_ = nullptr;
SettingsProvider* settings_;
- bool tooltipShown_;
+ bool tooltipShown_ = false;
MessageTarget messageTarget_;
- bool isOnline_;
+ bool isOnline_ = false;
};
}
diff --git a/Swift/QtUI/Trellis/QtDNDTabBar.h b/Swift/QtUI/Trellis/QtDNDTabBar.h
index e9b6771..6de04d5 100644
--- a/Swift/QtUI/Trellis/QtDNDTabBar.h
+++ b/Swift/QtUI/Trellis/QtDNDTabBar.h
@@ -36,9 +36,9 @@ class QtDNDTabBar : public QTabBar {
private:
int defaultTabHeight;
- int dragIndex;
+ int dragIndex = -1;
QString dragText;
- QWidget* dragWidget;
+ QWidget* dragWidget = nullptr;
};
}
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
index 3b3f74e..21aa7ca 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
@@ -76,7 +76,6 @@ namespace Swift {
QHBoxLayout* fillLayout;
ColorWidget* strokeColor;
ColorWidget* fillColor;
- QWidget* widget;
QPushButton* moveUpButton;
QPushButton* moveDownButton;
QSpinBox* widthBox;
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;
};