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 EUI64.test unit tests */
31 //#include "EUI64.test.hh"
32 //#include "EUI64.test.ih"
36 #include <senf/Socket/Protocols/AddressExceptions.hh>
38 #include <senf/Utils/auto_unit_test.hh>
39 #include <boost/test/test_tools.hpp>
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 SENF_AUTO_UNIT_TEST(eui64)
48 BOOST_CHECK( !eui.isMACCompatible() );
50 eui = senf::EUI64::from_mac(senf::MACAddress(0x102030405060ull));
51 boost::uint8_t data[] = { 0x10u, 0x20u, 0x30u, 0xffu, 0xfeu, 0x40u, 0x50u, 0x60u };
52 BOOST_CHECK_EQUAL_COLLECTIONS( eui.begin(), eui.end(), data, data+sizeof(data)/sizeof(data[0]) );
54 BOOST_CHECK( eui.isMACCompatible() );
55 BOOST_CHECK( ! eui.local() );
56 BOOST_CHECK( ! eui.group() );
57 BOOST_CHECK_EQUAL( eui.uint64(), 0x102030fffe405060ull );
59 BOOST_CHECK_EQUAL( eui, senf::EUI64::from_data(data) );
60 BOOST_CHECK_EQUAL( eui, senf::EUI64::from_string("10:20:30:ff-FE:40:50:60") );
62 BOOST_CHECK_THROW( senf::EUI64::from_string("123:20:30:40:50:60:70:80"),
63 senf::AddressSyntaxException );
64 BOOST_CHECK_THROW( senf::EUI64::from_string("12:20:30:40:50:60:70"),
65 senf::AddressSyntaxException );
66 BOOST_CHECK_THROW( senf::EUI64::from_string("12:20:30:40:50:60:70:8g"),
67 senf::AddressSyntaxException );
68 BOOST_CHECK_THROW( senf::EUI64::from_string("12:20:30:40:50:60:70:80:90"),
69 senf::AddressSyntaxException );
71 BOOST_CHECK_EQUAL( senf::EUI64::None, senf::EUI64(0) );
72 BOOST_CHECK(! senf::EUI64::None );
76 ss << std::uppercase << eui;
77 BOOST_CHECK_EQUAL( ss.str(), "10:20:30:FF-FE:40:50:60" );
81 BOOST_CHECK_EQUAL( eui, senf::EUI64(0x102030fffe405060ull) );
83 BOOST_CHECK( (ss >> eui).fail() );
88 ss << "01:02:03:04-05:06:07:108";
89 BOOST_CHECK( (ss >> eui).fail() );
93 SENF_AUTO_UNIT_TEST(eui64_fillRight)
95 std::string eui64Str ("01:02:03:ff-fe:04:05:06");
96 senf::EUI64 eui64 (senf::EUI64::from_string( eui64Str));
99 ss << std::left << eui64;
100 BOOST_CHECK_EQUAL( ss.str(), eui64Str);
103 //-/////////////////////////////////////////////////////////////////////////////////////////////////
110 // comment-column: 40
111 // c-file-style: "senf"
112 // indent-tabs-mode: nil
113 // ispell-local-dictionary: "american"
114 // compile-command: "scons -u test"