X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.test.cc;h=d738f60a24f076cb2e654746a563e8cb329588dc;hb=ee64a24a7ed1dfcdb7a12f14d7df3b043e564a30;hp=a33ccd4faaf804174273748ee1e3e86d6bc8a4ff;hpb=2d6585ff852e9d282c17003ba1db0b73eb3a8500;p=senf.git diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index a33ccd4..d738f60 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -1,6 +1,8 @@ +// $Id$ +// // Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// 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 @@ -28,7 +30,7 @@ #include #include "Packets.hh" -#include +#include "../Utils/auto_unit_test.hh" #include #define prefix_ @@ -55,15 +57,13 @@ namespace { struct BarPacketParser : public senf::PacketParserBase { - SENF_PACKET_PARSER_INIT(BarPacketParser); +# include SENF_FIXED_PARSER() - typedef senf::Parse_UInt16 Parse_Type; - typedef senf::Parse_Int32 Parse_Length; - typedef senf::Parse_UInt16 Parse_Reserved; + SENF_PARSER_FIELD( type, senf::UInt16Parser ); + SENF_PARSER_FIELD( length, senf::Int32Parser ); + SENF_PARSER_FIELD( reserved, senf::UInt16Parser ); - Parse_Type type() const { return parse (i()); } - Parse_Length length() const { return parse (i()+2); } - Parse_Reserved reserved() const { return parse (i()+6); } + SENF_PARSER_FINALIZE(BarPacketParser); }; struct BarPacketType @@ -152,10 +152,10 @@ BOOST_AUTO_UNIT_TEST(packet) packet.finalize(); BOOST_CHECK_EQUAL( packet.last().as()->type(), - BarPacket::type::parser::Parse_Type::value_type(-1) ); + BarPacket::type::parser::type_t::value_type(-1) ); packet.last().append(FooPacket::create()); packet.finalize(); - BOOST_CHECK_EQUAL( packet.next()->type(), 1u ); + BOOST_CHECK_EQUAL( packet.find()->type(), 1u ); BOOST_CHECK( packet.factory() == FooPacket::factory() ); @@ -166,25 +166,19 @@ BOOST_AUTO_UNIT_TEST(packet) BOOST_REQUIRE( packet.next() ); BOOST_REQUIRE( packet.next().is() ); BOOST_CHECK( packet.last().is() ); - BOOST_CHECK_EQUAL( packet.last()->type(), 1u ); + BOOST_CHECK_EQUAL( packet.last().rfind()->type(), 1u ); BOOST_CHECK_EQUAL( packet.next().size(), 11u ); BOOST_REQUIRE( packet.next().next() ); BOOST_CHECK( packet.next().next().is() ); BOOST_CHECK( ! packet.next().next().next() ); BOOST_CHECK_EQUAL( packet.next().next().data()[0], 0x81u ); - BOOST_CHECK( packet.first() == packet ); - BOOST_CHECK( packet.first(senf::nothrow) == packet ); - BOOST_CHECK( packet.last() == packet.last().prev() ); - BOOST_CHECK( packet.last(senf::nothrow) == packet.last().prev() ); - BOOST_CHECK( packet.findNext() == packet ); - BOOST_CHECK( packet.findNext(senf::nothrow) == packet ); - BOOST_CHECK( packet.last().findPrev() == packet.last() ); - BOOST_CHECK( packet.last().findPrev(senf::nothrow) == packet.last() ); + BOOST_CHECK( packet.first().find() == packet ); + BOOST_CHECK( packet.last().rfind() == packet.last().prev() ); + BOOST_CHECK( packet.find() == packet ); + BOOST_CHECK( packet.last().rfind() == packet.last() ); BOOST_CHECK( packet.next() == packet.next() ); - BOOST_CHECK( packet.next(senf::nothrow) == packet.next() ); - BOOST_CHECK( packet.last().prev() == packet ); - BOOST_CHECK( packet.last().prev(senf::nothrow) == packet ); + BOOST_CHECK( packet.last().prev().prev() == packet ); } BOOST_AUTO_UNIT_TEST(concretePacket)