4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief LLAddressing unit tests */
31 //#include "LLAddressing.test.hh"
32 //#include "LLAddressing.test.ih"
35 #include "LLAddressing.hh"
36 #include <senf/Utils/String.hh>
37 #include <senf/Socket/Protocols/AddressExceptions.hh>
39 #include <senf/Utils/auto_unit_test.hh>
40 #include <boost/test/test_tools.hpp>
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 SENF_AUTO_UNIT_TEST(llAddress)
47 using senf::LLSocketAddress;
52 BOOST_CHECK( ! addr );
53 BOOST_CHECK_EQUAL( addr.protocol(), 0u );
54 BOOST_CHECK_EQUAL( addr.interface(), "" );
55 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
56 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
57 BOOST_CHECK( ! addr.address() );
59 senf::MACAddress mac (senf::MACAddress::from_string("05-10-1A-2f-25-30"));
62 BOOST_CHECK_EQUAL( addr, LLSocketAddress(mac));
63 BOOST_CHECK_EQUAL( addr, LLSocketAddress(addr));
64 BOOST_CHECK_EQUAL( addr.address(), mac );
66 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
68 BOOST_CHECK_EQUAL( addr.protocol(), 123u );
72 LLSocketAddress addr (
73 senf::MACAddress::from_string("11-12-13-14-15-16"), "lo");
75 BOOST_CHECK_EQUAL( addr.protocol(), 0u );
76 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
77 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
78 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
79 BOOST_CHECK_EQUAL( senf::str(addr.address()), "11:12:13:14:15:16" );
83 LLSocketAddress addr (123, "lo");
85 BOOST_CHECK_EQUAL( addr.protocol(), 123u );
86 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
87 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
88 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
89 BOOST_CHECK( ! addr.address() );
93 BOOST_CHECK_THROW( LLSocketAddress addr("SENF_TEST_INVALID_INTERFACENAME"),
94 senf::UnknownInterfaceException );
96 LLSocketAddress addr ("lo");
98 BOOST_CHECK_EQUAL( addr.protocol(), 0u );
99 BOOST_CHECK_EQUAL( addr.interface(), "lo" );
100 BOOST_CHECK_EQUAL( addr.arptype(), 0u );
101 BOOST_CHECK_EQUAL( addr.pkttype(), LLSocketAddress::Undefined );
102 BOOST_CHECK( ! addr.address() );
104 BOOST_CHECK_EQUAL( LLSocketAddress("").interface(), "" );
108 //-/////////////////////////////////////////////////////////////////////////////////////////////////
115 // c-file-style: "senf"
116 // indent-tabs-mode: nil
117 // ispell-local-dictionary: "american"
118 // compile-command: "scons -u test"
119 // comment-column: 40