4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
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 LLAddressing unit tests */
26 //#include "LLAddressing.test.hh"
27 //#include "LLAddressing.test.ih"
30 #include <senf/Utils/String.hh>
31 #include "LLAddressing.hh"
33 #include <senf/Utils/auto_unit_test.hh>
34 #include <boost/test/test_tools.hpp>
37 ///////////////////////////////cc.p////////////////////////////////////////
39 BOOST_AUTO_UNIT_TEST(llAddress)
41 using senf::LLSocketAddress;
46 BOOST_CHECK( ! addr );
47 BOOST_CHECK_EQUAL( addr.protocol(), 0u );
48 BOOST_CHECK_EQUAL( addr.interface(), "" );
49 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
50 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
51 BOOST_CHECK( ! addr.address() );
53 senf::MACAddress mac (senf::MACAddress::from_string("05-10-1A-2f-25-30"));
56 BOOST_CHECK_EQUAL( addr, LLSocketAddress(mac));
57 BOOST_CHECK_EQUAL( addr, LLSocketAddress(addr));
58 BOOST_CHECK_EQUAL( addr.address(), mac );
60 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
62 BOOST_CHECK_EQUAL( addr.protocol(), 123u );
66 LLSocketAddress addr (
67 senf::MACAddress::from_string("11-12-13-14-15-16"), "lo");
69 BOOST_CHECK_EQUAL( addr.protocol(), 0u );
70 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
71 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
72 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
73 BOOST_CHECK_EQUAL( senf::str(addr.address()), "11:12:13:14:15:16" );
77 LLSocketAddress addr (123, "lo");
79 BOOST_CHECK_EQUAL( addr.protocol(), 123u );
80 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
81 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
82 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
83 BOOST_CHECK( ! addr.address() );
87 BOOST_CHECK_THROW( LLSocketAddress addr("SENF_TEST_INVALID_INTERFACENAME"),
88 senf::AddressSyntaxException );
90 LLSocketAddress addr ("lo");
92 BOOST_CHECK_EQUAL( addr.protocol(), 0u );
93 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
94 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
95 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
96 BOOST_CHECK( ! addr.address() );
98 BOOST_CHECK_EQUAL( LLSocketAddress("").interface(), "" );
102 ///////////////////////////////cc.e////////////////////////////////////////
109 // c-file-style: "senf"
110 // indent-tabs-mode: nil
111 // ispell-local-dictionary: "american"
112 // compile-command: "scons -u test"
113 // comment-column: 40