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 EUI64.test unit tests */
26 //#include "EUI64.test.hh"
27 //#include "EUI64.test.ih"
32 #include <senf/Utils/auto_unit_test.hh>
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
38 SENF_AUTO_UNIT_TEST(eui64)
42 BOOST_CHECK( !eui.isMACCompatible() );
44 eui = senf::EUI64::from_mac(senf::MACAddress(0x102030405060ull));
45 boost::uint8_t data[] = { 0x10u, 0x20u, 0x30u, 0xffu, 0xfeu, 0x40u, 0x50u, 0x60u };
46 BOOST_CHECK_EQUAL_COLLECTIONS( eui.begin(), eui.end(), data, data+sizeof(data)/sizeof(data[0]) );
48 BOOST_CHECK( eui.isMACCompatible() );
49 BOOST_CHECK( ! eui.local() );
50 BOOST_CHECK( ! eui.group() );
51 BOOST_CHECK_EQUAL( eui.uint64(), 0x102030fffe405060ull );
53 BOOST_CHECK_EQUAL( eui, senf::EUI64::from_data(data) );
54 BOOST_CHECK_EQUAL( eui, senf::EUI64::from_string("10:20:30:ff-FE:40:50:60") );
56 BOOST_CHECK_THROW( senf::EUI64::from_string("123:20:30:40:50:60:70:80"),
57 senf::AddressSyntaxException );
58 BOOST_CHECK_THROW( senf::EUI64::from_string("12:20:30:40:50:60:70"),
59 senf::AddressSyntaxException );
60 BOOST_CHECK_THROW( senf::EUI64::from_string("12:20:30:40:50:60:70:8g"),
61 senf::AddressSyntaxException );
62 BOOST_CHECK_THROW( senf::EUI64::from_string("12:20:30:40:50:60:70:80:90"),
63 senf::AddressSyntaxException );
65 BOOST_CHECK_EQUAL( senf::EUI64::None, senf::EUI64(0) );
66 BOOST_CHECK(! senf::EUI64::None );
70 ss << std::uppercase << eui;
71 BOOST_CHECK_EQUAL( ss.str(), "10:20:30:FF-FE:40:50:60" );
75 BOOST_CHECK_EQUAL( eui, senf::EUI64(0x102030fffe405060ull) );
77 BOOST_CHECK( (ss >> eui).fail() );
82 ss << "01:02:03:04-05:06:07:108";
83 BOOST_CHECK( (ss >> eui).fail() );
87 ///////////////////////////////cc.e////////////////////////////////////////
95 // c-file-style: "senf"
96 // indent-tabs-mode: nil
97 // ispell-local-dictionary: "american"
98 // compile-command: "scons -u test"