X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.test.cc;h=8da1546ca54543c64eb12d33a24db6ff03612f55;hb=c7512677a51c8ba551ab23611d6e99bdc7a7fdfa;hp=60b2bd2c493252afee52ec6676e76a7be2b25d08;hpb=f13c1275e48e97dceb7de7925793a4c69a5aeb61;p=senf.git diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index 60b2bd2..8da1546 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -26,14 +26,9 @@ // Custom includes #include -#include "PacketType.hh" -#include "PacketRegistry.hh" -#include "Packet.hh" -#include "ParseInt.hh" -#include "PacketParser.hh" -#include "DataPacket.hh" - -#include +#include "Packets.hh" + +#include "../Utils/auto_unit_test.hh" #include #define prefix_ @@ -60,15 +55,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::Parse_UInt16 ); + SENF_PARSER_FIELD( length, senf::Parse_Int32 ); + SENF_PARSER_FIELD( reserved, senf::Parse_UInt16 ); - 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 @@ -105,8 +98,8 @@ namespace { typedef BarPacketType::packet BarPacket; namespace reg { - senf::PacketRegistry::RegistrationProxy registerFoo(1u); - senf::PacketRegistry::RegistrationProxy registerBar(2u); + senf::PacketRegistry::RegistrationProxy registerFoo(1u); + senf::PacketRegistry::RegistrationProxy registerBar(2u); } } @@ -157,15 +150,15 @@ 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( packet.factory() == FooPacket::factory() ); - senf::Packet::byte data[] = { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x81, 0x82, 0x83 }; + senf::PacketData::byte data[] = { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x81, 0x82, 0x83 }; BarPacket::createAfter(packet,data); BOOST_REQUIRE( packet.next() ); @@ -194,7 +187,7 @@ BOOST_AUTO_UNIT_TEST(packet) BOOST_AUTO_UNIT_TEST(concretePacket) { - FooPacket::byte data[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + senf::PacketData::byte data[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; BOOST_CHECK_EQUAL( FooPacket::create().size(), 4u ); BOOST_CHECK_EQUAL( FooPacket::create(FooPacket::noinit).size(), 0u );