X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FSocket%2FProtocols%2FINet%2FINet6Address.test.cc;h=ec03f8da0e3a0eb88cdc4c057f0d44e46c6231e2;hb=72cc548dfc3fa72d14d4d8c1a178f162165e933a;hp=e342b27a60748817c3163ce428dd09e48d7037ca;hpb=afae50abf125df375ff1610b7a659f9b1da61bc0;p=senf.git diff --git a/senf/Socket/Protocols/INet/INet6Address.test.cc b/senf/Socket/Protocols/INet/INet6Address.test.cc index e342b27..ec03f8d 100644 --- a/senf/Socket/Protocols/INet/INet6Address.test.cc +++ b/senf/Socket/Protocols/INet/INet6Address.test.cc @@ -2,23 +2,28 @@ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund // -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. +// The contents of this file are subject to the Fraunhofer FOKUS Public License +// Version 1.0 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// http://senf.berlios.de/license.html // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// The Fraunhofer FOKUS Public License Version 1.0 is based on, +// but modifies the Mozilla Public License Version 1.1. +// See the full license text for the amendments. // -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +// for the specific language governing rights and limitations under the License. +// +// The Original Code is Fraunhofer FOKUS code. +// +// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. +// (registered association), Hansastraße 27 c, 80686 Munich, Germany. +// All Rights Reserved. +// +// Contributor(s): +// Stefan Bund /** \file \brief INet6Address unit tests */ @@ -30,12 +35,14 @@ #include "INet6Address.hh" #include #include +#include +#include #include #include #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// SENF_AUTO_UNIT_TEST(inet6Address) { @@ -79,12 +86,12 @@ SENF_AUTO_UNIT_TEST(inet6Address) BOOST_CHECK_EQUAL( addr3, INet6Address::from_string("1200::21") ); BOOST_CHECK_EQUAL( INet6Address::from_inet4address(INet4Address(0x01020304)), INet6Address::from_string("::ffff:1.2.3.4") ); + BOOST_CHECK( INet6Address::from_inet4address(INet4Address(0x01020304)).inet4Mapped()); BOOST_CHECK_THROW( INet6Address::from_string("1.2.3.4"), UnknownHostnameException ); BOOST_CHECK_EQUAL( INet6Address::from_string("1.2.3.4", INet6Address::ResolveINet4), INet6Address::from_string("::ffff:1.2.3.4") ); } - { INet6Address addr (INet6Address::from_string("2001:dead:beef::1002:3004")); BOOST_CHECK_EQUAL( addr.network(), senf::INet6Network( @@ -132,7 +139,6 @@ SENF_AUTO_UNIT_TEST(inet6Address) BOOST_CHECK( INet6Address::Loopback ); BOOST_CHECK( ! INet6Address::None ); } - { std::stringstream str; INet6Address addr; @@ -154,7 +160,6 @@ SENF_AUTO_UNIT_TEST(inet6Address) BOOST_CHECK( ! str.fail()); BOOST_CHECK_EQUAL(addr, INet6Address::from_string("2001:dead:beef::1002:3004")); } - { INet6Address addr; addr.network(0x2000010203040506ull); @@ -162,6 +167,15 @@ SENF_AUTO_UNIT_TEST(inet6Address) addr.id(1u); BOOST_CHECK_EQUAL( addr, INet6Address(0x2000u,0x0102u,0x0304u,0x0506u,0u,0u,0u,1u) ); } + { + using senf::MACAddress; + BOOST_CHECK_EQUAL( + INet6Address::from_mac( MACAddress::from_string("00-0C-29-C2-52-FF")), + INet6Address::from_string("fe80::20c:29ff:fec2:52ff") ); + BOOST_CHECK_EQUAL( + INet6Address::from_eui64( senf::EUI64::from_mac( MACAddress::from_string("a4:ba:db:fd:b8:76"))), + INet6Address::from_string("fe80::a6ba:dbff:fefd:b876") ); + } } SENF_AUTO_UNIT_TEST(inet6Network) @@ -214,7 +228,7 @@ SENF_AUTO_UNIT_TEST(inet6Network) } } -///////////////////////////////cc.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_