diff options
Diffstat (limited to 'Swiften/Queries/UnitTest')
-rw-r--r-- | Swiften/Queries/UnitTest/IQRouterTest.cpp | 30 | ||||
-rw-r--r-- | Swiften/Queries/UnitTest/RequestTest.cpp | 50 | ||||
-rw-r--r-- | Swiften/Queries/UnitTest/ResponderTest.cpp | 22 |
3 files changed, 51 insertions, 51 deletions
diff --git a/Swiften/Queries/UnitTest/IQRouterTest.cpp b/Swiften/Queries/UnitTest/IQRouterTest.cpp index d0d4911..0acb87b 100644 --- a/Swiften/Queries/UnitTest/IQRouterTest.cpp +++ b/Swiften/Queries/UnitTest/IQRouterTest.cpp @@ -4,9 +4,9 @@ * See the COPYING file for more information. */ +#include <memory> + #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -45,7 +45,7 @@ class IQRouterTest : public CppUnit::TestFixture { DummyIQHandler handler2(true, &testling); testling.removeHandler(&handler1); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(0, handler1.called); CPPUNIT_ASSERT_EQUAL(1, handler2.called); @@ -56,9 +56,9 @@ class IQRouterTest : public CppUnit::TestFixture { DummyIQHandler handler2(true, &testling); DummyIQHandler handler1(true, &testling); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); testling.removeHandler(&handler1); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(1, handler2.called); @@ -69,7 +69,7 @@ class IQRouterTest : public CppUnit::TestFixture { DummyIQHandler handler2(false, &testling); DummyIQHandler handler1(true, &testling); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(0, handler2.called); @@ -81,7 +81,7 @@ class IQRouterTest : public CppUnit::TestFixture { DummyIQHandler handler2(true, &testling); DummyIQHandler handler1(false, &testling); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(1, handler2.called); @@ -92,7 +92,7 @@ class IQRouterTest : public CppUnit::TestFixture { IQRouter testling(channel_); DummyIQHandler handler(false, &testling); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); CPPUNIT_ASSERT(channel_->iqs_[0]->getPayload<ErrorPayload>()); @@ -104,8 +104,8 @@ class IQRouterTest : public CppUnit::TestFixture { DummyIQHandler handler2(true, &testling); RemovingIQHandler handler1(&testling); - channel_->onIQReceived(boost::make_shared<IQ>()); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(1, handler1.called); CPPUNIT_ASSERT_EQUAL(2, handler2.called); @@ -115,7 +115,7 @@ class IQRouterTest : public CppUnit::TestFixture { IQRouter testling(channel_); testling.setFrom(JID("foo@bar.com/baz")); - testling.sendIQ(boost::make_shared<IQ>()); + testling.sendIQ(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom()); } @@ -123,7 +123,7 @@ class IQRouterTest : public CppUnit::TestFixture { void testSendIQ_WithoutFrom() { IQRouter testling(channel_); - testling.sendIQ(boost::make_shared<IQ>()); + testling.sendIQ(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(JID(), channel_->iqs_[0]->getFrom()); } @@ -133,7 +133,7 @@ class IQRouterTest : public CppUnit::TestFixture { testling.setFrom(JID("foo@bar.com/baz")); DummyIQHandler handler(false, &testling); - channel_->onIQReceived(boost::make_shared<IQ>()); + channel_->onIQReceived(std::make_shared<IQ>()); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getFrom()); } @@ -148,7 +148,7 @@ class IQRouterTest : public CppUnit::TestFixture { router->removeHandler(this); } - virtual bool handleIQ(boost::shared_ptr<IQ>) { + virtual bool handleIQ(std::shared_ptr<IQ>) { called++; return handle; } @@ -162,7 +162,7 @@ class IQRouterTest : public CppUnit::TestFixture { router->addHandler(this); } - virtual bool handleIQ(boost::shared_ptr<IQ>) { + virtual bool handleIQ(std::shared_ptr<IQ>) { called++; router->removeHandler(this); return false; diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp index 93aa9b1..56daffa 100644 --- a/Swiften/Queries/UnitTest/RequestTest.cpp +++ b/Swiften/Queries/UnitTest/RequestTest.cpp @@ -4,9 +4,9 @@ * See the COPYING file for more information. */ +#include <memory> + #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -56,25 +56,25 @@ class RequestTest : public CppUnit::TestFixture { MyRequest( IQ::Type type, const JID& receiver, - boost::shared_ptr<Payload> payload, + std::shared_ptr<Payload> payload, IQRouter* router) : Request(type, receiver, payload, router) { } - virtual void handleResponse(boost::shared_ptr<Payload> payload, ErrorPayload::ref error) { + virtual void handleResponse(std::shared_ptr<Payload> payload, ErrorPayload::ref error) { onResponse(payload, error); } public: - boost::signal<void (boost::shared_ptr<Payload>, ErrorPayload::ref)> onResponse; + boost::signal<void (std::shared_ptr<Payload>, ErrorPayload::ref)> onResponse; }; public: void setUp() { channel_ = new DummyIQChannel(); router_ = new IQRouter(channel_); - payload_ = boost::shared_ptr<Payload>(new MyPayload("foo")); - responsePayload_ = boost::shared_ptr<Payload>(new MyPayload("bar")); + payload_ = std::make_shared<MyPayload>("foo"); + responsePayload_ = std::make_shared<MyPayload>("bar"); responsesReceived_ = 0; } @@ -131,8 +131,8 @@ class RequestTest : public CppUnit::TestFixture { testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2)); testling.send(); - boost::shared_ptr<IQ> error = createError(JID("foo@bar.com/baz"),"test-id"); - boost::shared_ptr<Payload> errorPayload = boost::make_shared<ErrorPayload>(ErrorPayload::InternalServerError); + std::shared_ptr<IQ> error = createError(JID("foo@bar.com/baz"),"test-id"); + std::shared_ptr<Payload> errorPayload = std::make_shared<ErrorPayload>(ErrorPayload::InternalServerError); error->addPayload(errorPayload); channel_->onIQReceived(error); @@ -170,7 +170,7 @@ class RequestTest : public CppUnit::TestFixture { testling.onResponse.connect(boost::bind(&RequestTest::handleDifferentResponse, this, _1, _2)); testling.send(); - responsePayload_ = boost::make_shared<MyOtherPayload>(); + responsePayload_ = std::make_shared<MyOtherPayload>(); channel_->onIQReceived(createResponse(JID("foo@bar.com/baz"),"test-id")); CPPUNIT_ASSERT_EQUAL(1, responsesReceived_); @@ -179,12 +179,12 @@ class RequestTest : public CppUnit::TestFixture { } void testHandleIQ_RawXMLPayload() { - payload_ = boost::make_shared<RawXMLPayload>("<bla/>"); + payload_ = std::make_shared<RawXMLPayload>("<bla/>"); MyRequest testling(IQ::Get, JID("foo@bar.com/baz"), payload_, router_); testling.onResponse.connect(boost::bind(&RequestTest::handleRawXMLResponse, this, _1, _2)); testling.send(); - responsePayload_ = boost::make_shared<MyOtherPayload>(); + responsePayload_ = std::make_shared<MyOtherPayload>(); channel_->onIQReceived(createResponse(JID("foo@bar.com/baz"),"test-id")); CPPUNIT_ASSERT_EQUAL(1, responsesReceived_); @@ -197,7 +197,7 @@ class RequestTest : public CppUnit::TestFixture { testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2)); testling.send(); - boost::shared_ptr<IQ> response = createResponse(JID("foo@bar.com/baz"),"test-id"); + std::shared_ptr<IQ> response = createResponse(JID("foo@bar.com/baz"),"test-id"); response->setType(IQ::Get); channel_->onIQReceived(response); @@ -211,7 +211,7 @@ class RequestTest : public CppUnit::TestFixture { testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2)); testling.send(); - boost::shared_ptr<IQ> response = createResponse(JID("foo@bar.com/baz"), "test-id"); + std::shared_ptr<IQ> response = createResponse(JID("foo@bar.com/baz"), "test-id"); response->setType(IQ::Set); channel_->onIQReceived(response); @@ -315,41 +315,41 @@ class RequestTest : public CppUnit::TestFixture { private: - void handleResponse(boost::shared_ptr<Payload> p, ErrorPayload::ref e) { + void handleResponse(std::shared_ptr<Payload> p, ErrorPayload::ref e) { if (e) { receivedErrors.push_back(*e); } else { - boost::shared_ptr<MyPayload> payload(boost::dynamic_pointer_cast<MyPayload>(p)); + std::shared_ptr<MyPayload> payload(std::dynamic_pointer_cast<MyPayload>(p)); CPPUNIT_ASSERT(payload); CPPUNIT_ASSERT_EQUAL(std::string("bar"), payload->text_); ++responsesReceived_; } } - void handleDifferentResponse(boost::shared_ptr<Payload> p, ErrorPayload::ref e) { + void handleDifferentResponse(std::shared_ptr<Payload> p, ErrorPayload::ref e) { CPPUNIT_ASSERT(!e); CPPUNIT_ASSERT(!p); ++responsesReceived_; } - void handleRawXMLResponse(boost::shared_ptr<Payload> p, ErrorPayload::ref e) { + void handleRawXMLResponse(std::shared_ptr<Payload> p, ErrorPayload::ref e) { CPPUNIT_ASSERT(!e); CPPUNIT_ASSERT(p); - CPPUNIT_ASSERT(boost::dynamic_pointer_cast<MyOtherPayload>(p)); + CPPUNIT_ASSERT(std::dynamic_pointer_cast<MyOtherPayload>(p)); ++responsesReceived_; } - boost::shared_ptr<IQ> createResponse(const JID& from, const std::string& id) { - boost::shared_ptr<IQ> iq(new IQ(IQ::Result)); + std::shared_ptr<IQ> createResponse(const JID& from, const std::string& id) { + std::shared_ptr<IQ> iq(new IQ(IQ::Result)); iq->setFrom(from); iq->addPayload(responsePayload_); iq->setID(id); return iq; } - boost::shared_ptr<IQ> createError(const JID& from, const std::string& id) { - boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); + std::shared_ptr<IQ> createError(const JID& from, const std::string& id) { + std::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setFrom(from); iq->setID(id); return iq; @@ -358,8 +358,8 @@ class RequestTest : public CppUnit::TestFixture { private: IQRouter* router_; DummyIQChannel* channel_; - boost::shared_ptr<Payload> payload_; - boost::shared_ptr<Payload> responsePayload_; + std::shared_ptr<Payload> payload_; + std::shared_ptr<Payload> responsePayload_; int responsesReceived_; std::vector<ErrorPayload> receivedErrors; }; diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index c3474f2..98c1448 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -4,9 +4,9 @@ * See the COPYING file for more information. */ +#include <memory> + #include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -34,7 +34,7 @@ class ResponderTest : public CppUnit::TestFixture { void setUp() { channel_ = new DummyIQChannel(); router_ = new IQRouter(channel_); - payload_ = boost::make_shared<SoftwareVersion>("foo"); + payload_ = std::make_shared<SoftwareVersion>("foo"); } void tearDown() { @@ -110,15 +110,15 @@ class ResponderTest : public CppUnit::TestFixture { void testHandleIQ_NoPayload() { MyResponder testling(router_); - CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(boost::make_shared<IQ>(IQ::Get))); + CPPUNIT_ASSERT(!dynamic_cast<IQHandler*>(&testling)->handleIQ(std::make_shared<IQ>(IQ::Get))); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.getPayloads_.size())); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(testling.setPayloads_.size())); } private: - boost::shared_ptr<IQ> createRequest(IQ::Type type) { - boost::shared_ptr<IQ> iq(new IQ(type)); + std::shared_ptr<IQ> createRequest(IQ::Type type) { + std::shared_ptr<IQ> iq(new IQ(type)); iq->addPayload(payload_); iq->setID("myid"); iq->setFrom(JID("foo@bar.com/baz")); @@ -130,13 +130,13 @@ class ResponderTest : public CppUnit::TestFixture { public: MyResponder(IQRouter* router) : Responder<SoftwareVersion>(router), getRequestResponse_(true), setRequestResponse_(true) {} - virtual bool handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<SoftwareVersion> payload) { + virtual bool handleGetRequest(const JID& from, const JID&, const std::string& id, std::shared_ptr<SoftwareVersion> payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); CPPUNIT_ASSERT_EQUAL(std::string("myid"), id); getPayloads_.push_back(payload); return getRequestResponse_; } - virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<SoftwareVersion> payload) { + virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, std::shared_ptr<SoftwareVersion> payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); CPPUNIT_ASSERT_EQUAL(std::string("myid"), id); setPayloads_.push_back(payload); @@ -145,14 +145,14 @@ class ResponderTest : public CppUnit::TestFixture { bool getRequestResponse_; bool setRequestResponse_; - std::vector<boost::shared_ptr<SoftwareVersion> > getPayloads_; - std::vector<boost::shared_ptr<SoftwareVersion> > setPayloads_; + std::vector<std::shared_ptr<SoftwareVersion> > getPayloads_; + std::vector<std::shared_ptr<SoftwareVersion> > setPayloads_; }; private: IQRouter* router_; DummyIQChannel* channel_; - boost::shared_ptr<SoftwareVersion> payload_; + std::shared_ptr<SoftwareVersion> payload_; }; CPPUNIT_TEST_SUITE_REGISTRATION(ResponderTest); |