2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief INet4Address.test unit tests */
24 //#include "INet4Address.test.hh"
25 //#include "INet4Address.test.ih"
28 #include <arpa/inet.h>
30 #include "INet4Address.hh"
32 #include <boost/test/auto_unit_test.hpp>
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
38 BOOST_AUTO_UNIT_TEST(inet4Address)
40 senf::INet4Address addr (senf::INet4Address::from_string("127.0.0.1"));
41 BOOST_CHECK_EQUAL( addr, senf::INet4Address::Loopback );
42 BOOST_CHECK( addr != senf::INet4Address::Broadcast );
44 addr = senf::INet4Address::from_string("localhost");
45 BOOST_CHECK_EQUAL( addr, senf::INet4Address::Loopback );
46 BOOST_CHECK( addr.loopback() );
48 char data[] = { 128, 129, 130, 131 };
49 addr = senf::INet4Address::from_data(data);
50 BOOST_CHECK_EQUAL( addr, senf::INet4Address::from_string("128.129.130.131") );
51 BOOST_CHECK_EQUAL( addr.inaddr(), htonl(0x80818283u) );
52 BOOST_CHECK_EQUAL( addr.address(), 0x80818283u );
54 BOOST_CHECK( ! addr.loopback() );
55 BOOST_CHECK( ! addr.local() );
56 BOOST_CHECK( senf::INet4Address::from_string("192.168.1.2").local() );
57 BOOST_CHECK( ! addr.multicast() );
58 BOOST_CHECK( senf::INet4Address::from_string("224.1.2.3").multicast() );
59 BOOST_CHECK( ! addr.broadcast() );
60 BOOST_CHECK( senf::INet4Address::from_string("255.255.255.255").broadcast() );
62 BOOST_CHECK( ! senf::INet4Address() );
64 std::stringstream str;
66 BOOST_CHECK_EQUAL( str.str(), "128.129.130.131" );
69 ///////////////////////////////cc.e////////////////////////////////////////
77 // c-file-style: "senf"
78 // indent-tabs-mode: nil
79 // ispell-local-dictionary: "american"
80 // compile-command: "scons -u test"