From 6c4f0aa3eaa0de86457dbc734ea552cd03a67a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 1 Oct 2014 08:07:52 +0200 Subject: Initial import of psocksxx version 0.0.5-1 --- test/nsockaddr_test.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 test/nsockaddr_test.cpp (limited to 'test/nsockaddr_test.cpp') diff --git a/test/nsockaddr_test.cpp b/test/nsockaddr_test.cpp new file mode 100644 index 0000000..1eceb87 --- /dev/null +++ b/test/nsockaddr_test.cpp @@ -0,0 +1,76 @@ +/* +* psocksxx - A C++ wrapper for POSIX sockets +* Copyright (C) 2013 Uditha Atukorala +* +* This software library is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation; either version 3 of the License, or +* (at your option) any later version. +* +* This software library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this software library. If not, see . +* +*/ + +#include "nsockaddr_test.h" + +#include + + +// register the fixture into the 'registry' +CPPUNIT_TEST_SUITE_REGISTRATION( nsockaddr_test ); + +// use namespace psocksxx +using namespace psocksxx; + + +void nsockaddr_test::test_constructor_localhost() { + + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( "localhost", 1234 ) ); + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( "127.0.0.1", 4321 ) ); + +} + + +void nsockaddr_test::test_constructor_remote() { + + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( "www.example.com", 1234 ) ); + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( "1.2.3.4", 80 ) ); + +} + + +void nsockaddr_test::test_constructor_fail() { + + CPPUNIT_ASSERT_THROW( nsockaddr a( "invalid.domain", 1234 ), sockexception ); + CPPUNIT_ASSERT_THROW( nsockaddr a( "1.2.3.", 1234 ), sockexception ); + +} + + +void nsockaddr_test::test_constructor_local_any() { + + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( 1234 ) ); + +} + + +void nsockaddr_test::test_constructor_local_service() { + + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( "localhost", "1234" ) ); + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( 0, "ftp" ) ); + +} + + +void nsockaddr_test::test_constructor_remote_service() { + + CPPUNIT_ASSERT_NO_THROW( nsockaddr a( "www.example.com", "http" ) ); + +} + -- cgit v1.2.3