4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <g0dil@berlios.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.
24 \brief INet4Address.test unit tests */
26 //#include "INet4Address.test.hh"
27 //#include "INet4Address.test.ih"
30 #include <arpa/inet.h>
32 #include "INet4Address.hh"
34 #include <boost/test/auto_unit_test.hpp>
35 #include <boost/test/test_tools.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
40 BOOST_AUTO_UNIT_TEST(inet4Address)
42 senf::INet4Address addr (senf::INet4Address::from_string("127.0.0.1"));
43 BOOST_CHECK_EQUAL( addr, senf::INet4Address::Loopback );
44 BOOST_CHECK( addr != senf::INet4Address::Broadcast );
46 addr = senf::INet4Address::from_string("localhost");
47 BOOST_CHECK_EQUAL( addr, senf::INet4Address::Loopback );
48 BOOST_CHECK( addr.loopback() );
50 char data[] = { 128, 129, 130, 131 };
51 addr = senf::INet4Address::from_data(data);
52 BOOST_CHECK_EQUAL( addr, senf::INet4Address::from_string("128.129.130.131") );
53 BOOST_CHECK_EQUAL( addr.inaddr(), htonl(0x80818283u) );
54 BOOST_CHECK_EQUAL( addr.address(), 0x80818283u );
56 BOOST_CHECK( ! addr.loopback() );
57 BOOST_CHECK( ! addr.local() );
58 BOOST_CHECK( senf::INet4Address::from_string("192.168.1.2").local() );
59 BOOST_CHECK( ! addr.multicast() );
60 BOOST_CHECK( senf::INet4Address::from_string("224.1.2.3").multicast() );
61 BOOST_CHECK( ! addr.broadcast() );
62 BOOST_CHECK( senf::INet4Address::from_string("255.255.255.255").broadcast() );
64 BOOST_CHECK( ! senf::INet4Address() );
66 std::stringstream str;
68 BOOST_CHECK_EQUAL( str.str(), "128.129.130.131" );
71 ///////////////////////////////cc.e////////////////////////////////////////
79 // c-file-style: "senf"
80 // indent-tabs-mode: nil
81 // ispell-local-dictionary: "american"
82 // compile-command: "scons -u test"