-// $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 <Philipp.Batroff@fokus.fraunhofer.de>
//
-// 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 <pug@berlios.de>
// Custom includes
#include <senf/Packets/Packets.hh>
-#include "IPv6ExtOptionType.hh"
+#include "IPv6ExtOptions.hh"
#include "ListOptionTypeParser.hh"
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
#define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
namespace {
struct VoidPacket : public senf::PacketTypeBase
SENF_PARSER_FIELD( size, senf::UInt8Parser );
typedef senf::detail::FixedAuxParserPolicy<senf::UInt8Parser, 1u> ListOptionTypeAuxPolicy;
- typedef senf::detail::ListOptionTypeParser_Policy<senf::GenericOptTypeTLVPacketParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
+ typedef senf::detail::ListOptionTypeParser_Policy<
+ senf::IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
typedef senf::ListParser<ListOptionTypePolicy> ListOptionTypeParser;
SENF_PARSER_FIELD ( list, ListOptionTypeParser);
};
}
-BOOST_AUTO_UNIT_TEST(ListOptionTypeParser)
+SENF_AUTO_UNIT_TEST(ListOptionTypeParser)
{
senf::PacketInterpreterBase::ptr pi (senf::PacketInterpreter<VoidPacket>::create(
OptionParser::init_bytes));
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<VoidPacket>::create(
OptionParser::init_bytes));
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<unsigned char> d (2, 0xab);
+ std::vector<unsigned char> d1 (1, 0x77);
+ std::vector<unsigned char> 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 );
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
BOOST_CHECK_EQUAL( c.empty(), true);
}
}
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
+\f
// Local Variables:
// mode: c++
// fill-column: 100