X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FDefaultBundle%2FListOptionTypeParser.test.cc;h=69b52483c4e08d6743916ec8bff802b12bd2f900;hb=HEAD;hp=c0802d8011540a39676fae8f48b8e2c74854be52;hpb=328a72eb2f360d08f2d618ef6aae2ac6b42d76ab;p=senf.git diff --git a/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc b/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc index c0802d8..69b5248 100644 --- a/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc +++ b/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc @@ -1,35 +1,40 @@ -// $Id: ListOptionTypeParser.test.cc 1345 2009-08-26 15:40:55Z pug $ +// $Id$ // // Copyright (C) 2009 // Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Philipp Batroff // -// 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): +// Philipp Batroff // Custom includes #include -#include "IPv6ExtOptionType.hh" +#include "IPv6ExtOptions.hh" #include "ListOptionTypeParser.hh" #include #include #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace { struct VoidPacket : public senf::PacketTypeBase @@ -42,7 +47,7 @@ namespace { SENF_PARSER_FIELD( size, senf::UInt8Parser ); typedef senf::detail::FixedAuxParserPolicy ListOptionTypeAuxPolicy; typedef senf::detail::ListOptionTypeParser_Policy< - senf::IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy; + senf::IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy; typedef senf::ListParser ListOptionTypeParser; SENF_PARSER_FIELD ( list, ListOptionTypeParser); @@ -50,7 +55,7 @@ namespace { }; } -BOOST_AUTO_UNIT_TEST(ListOptionTypeParser) +SENF_AUTO_UNIT_TEST(ListOptionTypeParser) { senf::PacketInterpreterBase::ptr pi (senf::PacketInterpreter::create( OptionParser::init_bytes)); @@ -75,7 +80,7 @@ BOOST_AUTO_UNIT_TEST(ListOptionTypeParser) BOOST_CHECK_EQUAL( p.list().empty(), false ); } -BOOST_AUTO_UNIT_TEST(ListOptionTypeParser_container) +SENF_AUTO_UNIT_TEST(ListOptionTypeParser_container) { senf::PacketInterpreterBase::ptr pi (senf::PacketInterpreter::create( OptionParser::init_bytes)); @@ -89,19 +94,19 @@ BOOST_AUTO_UNIT_TEST(ListOptionTypeParser_container) BOOST_CHECK_EQUAL( c.bytes(), 0u ); // padding bytes wont be in here, added/removed automatically in destructor BOOST_CHECK( c.begin() == c.end() ); - unsigned char d[] = {0x65, 0x02, 0x40, 0x34}; - unsigned char d1[] = {0x03, 0x01, 0x77}; - unsigned char d2[] = {0x07, 0x01, 0x13}; + std::vector d (2, 0xab); + std::vector d1 (1, 0x77); + std::vector d2 (1, 0x13); - SENF_CHECK_NO_THROW( c.push_back( d ) ); + SENF_CHECK_NO_THROW( c.push_back( std::make_pair(0x65, d) )); BOOST_CHECK_EQUAL( c.bytes(), 4u ); BOOST_CHECK_EQUAL( c.size(), 1u ); - SENF_CHECK_NO_THROW( c.push_back( d1 ) ); + SENF_CHECK_NO_THROW( c.push_back( std::make_pair(0x03, d1) )); BOOST_CHECK_EQUAL( c.bytes(), 7u ); BOOST_CHECK_EQUAL( c.size(), 2u ); - SENF_CHECK_NO_THROW( c.push_back( d2 ) ); + SENF_CHECK_NO_THROW( c.push_back( std::make_pair(0x07, d2) )); BOOST_CHECK_EQUAL( c.bytes(), 10u ); BOOST_CHECK_EQUAL( c.size(), 3u ); @@ -109,16 +114,16 @@ BOOST_AUTO_UNIT_TEST(ListOptionTypeParser_container) BOOST_CHECK_EQUAL( cIter->altAction(), 1u); BOOST_CHECK_EQUAL( cIter->changeFlag(), 1u); BOOST_CHECK_EQUAL( cIter->optionType(), 5u); - BOOST_CHECK_EQUAL( cIter->optionLength(), 2u); - BOOST_CHECK_EQUAL( *(boost::begin(cIter->value()) ), 0x40); - BOOST_CHECK_EQUAL( *(boost::next(boost::begin(cIter->value()) )), 0x34); + BOOST_CHECK_EQUAL( cIter->length(), 2u); + BOOST_CHECK_EQUAL( *(boost::begin(cIter->value()) ), 0xab); + BOOST_CHECK_EQUAL( *(boost::next(boost::begin(cIter->value()) )), 0xab); cIter++; BOOST_CHECK_EQUAL( cIter->optionType(), 3u); - BOOST_CHECK_EQUAL( cIter->optionLength(), 1u); + BOOST_CHECK_EQUAL( cIter->length(), 1u); BOOST_CHECK_EQUAL( *(boost::begin(cIter->value() )), 0x77); cIter++; BOOST_CHECK_EQUAL( cIter->optionType(), 7u); - BOOST_CHECK_EQUAL( cIter->optionLength(), 1u); + BOOST_CHECK_EQUAL( cIter->length(), 1u); BOOST_CHECK_EQUAL( *(boost::begin(cIter->value())), 0x13); //deletes first element @@ -138,7 +143,9 @@ BOOST_AUTO_UNIT_TEST(ListOptionTypeParser_container) BOOST_CHECK_EQUAL( c.empty(), true); } } +//-///////////////////////////////////////////////////////////////////////////////////////////////// + // Local Variables: // mode: c++ // fill-column: 100