From d64f8bdf750ebc28be238ced2e41bab6ef3c883a Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Thu, 15 Dec 2011 20:55:55 +0100 Subject: [PATCH] Unittest for StreamConnection --- test/test_StreamConnection.hpp | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/test_StreamConnection.hpp diff --git a/test/test_StreamConnection.hpp b/test/test_StreamConnection.hpp new file mode 100644 index 0000000..9ece1cf --- /dev/null +++ b/test/test_StreamConnection.hpp @@ -0,0 +1,59 @@ +#include + +#include "Fixture.hpp" + +#include "StreamConnection.hpp" + +class TestStreamConnection : public CxxTest::TestSuite +{ +private: + + class DummyStreamConnection : public StreamConnection + { + public: + + DummyStreamConnection(const std::string host, const std::string port) + : StreamConnection(host, port) + { + TRACE; + } + + virtual ~DummyStreamConnection() + { + TRACE; + } + + Connection* clone(const int) { return 0; } + bool bind() { return true; } + bool send(const void*, const size_t) { return true; } + bool receive() { return true; } + int getSocket() const { return 0; } + + bool connect() { return true; } + bool disconnect() { return true; } + bool listen(const int) { return true; } + bool accept(int &) { return true; } + bool closed() const { return true; } + + }; // StreamConnection + + +public: + + void testStreamConnection() + { + TEST_HEADER; + + DummyStreamConnection 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") ); + } + +};