//
// Copyright (C) 2007
// Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Stefan Bund <g0dil@berlios.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):
+// Stefan Bund <g0dil@berlios.de>
/** \file
\brief VariantParser unit tests */
#include <boost/test/test_tools.hpp>
#define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
SENF_AUTO_UNIT_TEST(VariantParser)
{
typedef senf::ArrayParser<10, senf::UInt8Parser> Array10;
typedef senf::VariantParser< senf::detail::FixedAuxParserPolicy<senf::UInt8Parser, 1>,
boost::mpl::vector<senf::VoidPacketParser, Array10, senf:: UInt32Parser> > Variant;
-
+
unsigned char data[] = { 0x01, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1A, 0x1B };
senf::DataPacket p (senf::DataPacket::create(data));
BOOST_REQUIRE_EQUAL( p.data().size(), 11u );
BOOST_REQUIRE_EQUAL( v.variant(), 0u );
BOOST_CHECK_EQUAL( senf::bytes(v), 0u );
-
+
v.init<2>();
// v invalidated
}
};
}
-// We can't use the unnamed namespace here since there's a bug in gcc-4.2.3 which is
+// We can't use the unnamed namespace here since there's a bug in gcc-4.2.3 which is
// the default version of gcc on ubuntu hardy :-(
// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34213
namespace VariantParser_test_cc_anon_namespace {
-
+
struct SubParser : public senf::PacketParserBase
- {
+ {
# include SENF_FIXED_PARSER()
SENF_PARSER_FIELD( foo, senf::UInt32Parser );
SENF_PARSER_BITFIELD_RO( len, 4, unsigned );
SENF_PARSER_BITFIELD_RO( type, 4, unsigned );
// just here so the second variant is 'var'
- SENF_PARSER_VARIANT( value, len,
+ SENF_PARSER_VARIANT( value, len,
(senf::VoidPacketParser)
(senf::UInt8Parser)
(senf::UInt16Parser)
SENF_PARSER_FINALIZE(TestParser);
};
-
+
}
using namespace VariantParser_test_cc_anon_namespace;
SENF_AUTO_UNIT_TEST(VariantParserMacro)
{
senf::DataPacket p (senf::DataPacket::create(senf::init_bytes<TestParser>::value));
-
+
{
TestParser v (p.data().begin(), & p.data());
v.init();
}
}
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#undef prefix_
\f