Socket: Move shutdown from SocketProtocol::close() to INetSocketProtocol::close()
[senf.git] / Packets / Packet.test.cc
index 8c28f73..35b3214 100644 (file)
@@ -28,6 +28,7 @@
 
 // Custom includes
 #include <sstream>
+#include <boost/static_assert.hpp>
 #include "Packets.hh"
 
 #include "../Utils/auto_unit_test.hh"
@@ -126,6 +127,11 @@ namespace {
     struct ComplexEmptyAnnotation : senf::ComplexAnnotation
     {};
 
+    struct InvalidAnnotation
+    {
+        std::string value;
+    };
+
 }
 
 BOOST_AUTO_UNIT_TEST(packet)
@@ -251,6 +257,17 @@ BOOST_AUTO_UNIT_TEST(concretePacket)
     BOOST_CHECK_EQUAL( BarPacket::create()->reserved(), 0xA0A0u );
 }
 
+BOOST_AUTO_UNIT_TEST(packetAssign)
+{
+    BarPacket bar1 (BarPacket::create());
+    BarPacket bar2 (BarPacket::create());
+
+    bar2->type() << 0x2A2Bu;
+    bar1.parser() << bar2;
+    
+    BOOST_CHECK_EQUAL( bar1->type(), 0x2A2Bu );
+}
+
 BOOST_AUTO_UNIT_TEST(packetAnnotation)
 {
     senf::Packet packet (FooPacket::create());
@@ -273,6 +290,26 @@ BOOST_AUTO_UNIT_TEST(packetAnnotation)
     BOOST_CHECK( ! senf::detail::AnnotationIndexer<ComplexEmptyAnnotation>::Small );
 }
 
+#ifdef COMPILE_CHECK
+
+COMPILE_FAIL(invalidAnnotation)
+{
+#if 0 // The traits check fails for user defined but trivial constructors so ...
+#   ifdef BOOST_HAS_TYPE_TRAITS_INTRINSICS
+
+    senf::Packet packet (FooPacket::create());
+    (void) packet.annotation<InvalidAnnotation>();
+
+#   else
+#   endif
+#endif
+
+    invalid_annotation_check_disabled();
+
+}
+
+#endif
+
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_