X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.test.cc;h=baa89f0ac194ea4f608a6050ec9d7776ce0fd545;hb=ac86c2bb40746fbedf70a19af3307e5da642b04a;hp=7331b992235f1b68cd663c590e8684cfed062676;hpb=47368f306a577d1e46df69a7f729bd3893cbe5e7;p=senf.git diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index 7331b99..baa89f0 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -26,12 +26,7 @@ // Custom includes #include -#include "PacketType.hh" -#include "PacketRegistry.hh" -#include "Packet.hh" -#include "ParseInt.hh" -#include "PacketParser.hh" -#include "DataPacket.hh" +#include "Packets.hh" #include #include @@ -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 ); @@ -242,4 +235,5 @@ BOOST_AUTO_UNIT_TEST(concretePacket) // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" +// comment-column: 40 // End: