Link statically against boost_unit_test_framework library
[senf.git] / Packets / Packet.test.cc
index 7331b99..8da1546 100644 (file)
 
 // Custom includes
 #include <sstream>
-#include "PacketType.hh"
-#include "PacketRegistry.hh"
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "PacketParser.hh"
-#include "DataPacket.hh"
-
-#include <boost/test/auto_unit_test.hpp>
+#include "Packets.hh"
+
+#include "../Utils/auto_unit_test.hh"
 #include <boost/test/test_tools.hpp>
 
 #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<Parse_Type> (i()); }
-        Parse_Length length() const { return parse<Parse_Length> (i()+2); }
-        Parse_Reserved reserved() const { return parse<Parse_Reserved> (i()+6); }
+        SENF_PARSER_FINALIZE(BarPacketParser);
     };
 
     struct BarPacketType 
@@ -105,8 +98,8 @@ namespace {
     typedef BarPacketType::packet BarPacket;
 
     namespace reg {
-        senf::PacketRegistry<RegTag>::RegistrationProxy<FooPacketType> registerFoo(1u);
-        senf::PacketRegistry<RegTag>::RegistrationProxy<BarPacketType> registerBar(2u);
+        senf::PacketRegistry<RegTag>::RegistrationProxy<FooPacket> registerFoo(1u);
+        senf::PacketRegistry<RegTag>::RegistrationProxy<BarPacket> registerBar(2u);
     }
 
 }
@@ -157,15 +150,15 @@ BOOST_AUTO_UNIT_TEST(packet)
     
     packet.finalize();
     BOOST_CHECK_EQUAL( packet.last().as<BarPacket>()->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<BarPacket>()->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: