4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 //#include "INetAddressing.test.hh"
26 //#include "INetAddressing.test.ih"
29 #include "INetAddressing.hh"
31 #include <boost/test/auto_unit_test.hpp>
32 #include <boost/test/test_tools.hpp>
35 ///////////////////////////////cc.p////////////////////////////////////////
37 BOOST_AUTO_UNIT_TEST(inet4Address)
39 using satcom::lib::INet4Address;
40 using satcom::lib::InvalidINetAddressException;
45 addr = "127.0.0.1:12345";
49 INet4Address addr1("127.0.0.1:12345");
50 INet4Address addr2(std::string("127.0.0.1:12345"));
51 INet4Address addr3("127.0.0.1",12345);
54 BOOST_CHECK_EQUAL( INet4Address("127.0.0.1:12345"), INet4Address("127.0.0.1",12345) );
56 BOOST_CHECK_THROW( INet4Address("127.0.0.1"), InvalidINetAddressException );
57 BOOST_CHECK_THROW( INet4Address("foo@bar:12345"), InvalidINetAddressException );
58 BOOST_CHECK_THROW( INet4Address("127.0.0.1:1234a"), InvalidINetAddressException );
59 BOOST_CHECK_THROW( INet4Address("foo@bar",12345), InvalidINetAddressException );
61 BOOST_CHECK_EQUAL( INet4Address("127.0.0.1:12345").host(), "127.0.0.1" );
62 BOOST_CHECK_EQUAL( INet4Address("127.0.0.1:12345").port(), 12345u );
63 BOOST_CHECK_EQUAL( INet4Address("127.0.0.1:12345").str(), "127.0.0.1:12345" );
66 INet4Address addr("127.0.0.1:12345");
67 BOOST_CHECK_EQUAL( reinterpret_cast< ::sockaddr_in * >(addr.sockaddr_p())->sin_port,
69 BOOST_CHECK_EQUAL( reinterpret_cast< ::sockaddr_in * >(addr.sockaddr_p())->sin_addr.s_addr,
70 htonl(INADDR_LOOPBACK) );
74 BOOST_CHECK_EQUAL( s.str(), "127.0.0.1:12345" );
78 BOOST_AUTO_UNIT_TEST(inet6Address)
82 ///////////////////////////////cc.e////////////////////////////////////////
88 // c-file-style: "satcom"