From 1bd546392ffa3c426345196df875ae5eba2dc152 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Wed, 14 Dec 2011 20:53:09 +0100 Subject: [PATCH] unittest for Connection --- test/test_Connection.hpp | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 test/test_Connection.hpp diff --git a/test/test_Connection.hpp b/test/test_Connection.hpp new file mode 100644 index 0000000..3bebbef --- /dev/null +++ b/test/test_Connection.hpp @@ -0,0 +1,77 @@ +#include + +#include "Fixture.hpp" + +#include "Connection.hpp" + +class TestConnection : public CxxTest::TestSuite +{ +private: + + class DummyConnection : public Connection + { + public: + + DummyConnection(const std::string host, const std::string port) + : Connection(host, port) + { + TRACE; + } + + ~DummyConnection() + { + TRACE; + } + + Connection* clone(const int) + { + TRACE; + return 0; + } + + + bool bind() + { + TRACE; + return true; + } + + + bool send(const void*, const size_t) + { + TRACE; + return true; + } + + bool receive() + { + TRACE; + return true; + } + + int getSocket() const + { + TRACE; + return 0; + } + + }; // DummyConnection + + +public: + + void testConnection() + { + DummyConnection c("localhost", "1234"); + + TS_ASSERT_EQUALS (c.getHost() , std::string("localhost") ); + TS_ASSERT_EQUALS (c.getPort() , std::string("1234") ); + + c.setHost("127.0.0.1"); + c.setPort("4455"); + + TS_ASSERT_EQUALS (c.getHost() , std::string("127.0.0.1") ); + TS_ASSERT_EQUALS (c.getPort() , std::string("4455") ); + } + +};