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/Queries | |
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/Queries')
-rw-r--r-- | Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp | 17 | ||||
-rw-r--r-- | Swiften/Queries/UnitTest/ResponderTest.cpp | 27 |
2 files changed, 21 insertions, 23 deletions
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_; }; |