// Custom includes
#include <sstream>
#include <boost/static_assert.hpp>
+#include <boost/cstdint.hpp>
#include "Packets.hh"
#include <senf/Utils/auto_unit_test.hh>
}
struct IntAnnotation {
- unsigned value;
+ boost::uint32_t value;
};
std::ostream & operator<<(std::ostream & os, IntAnnotation const & v)
struct ComplexAnnotation : senf::ComplexAnnotation
{
- ComplexAnnotation() : s(), i() {}
+ ComplexAnnotation() : s("empty"), i(-1) {}
std::string s;
- int i;
+ boost::int32_t i;
+ // padding so the size does not depend on the platform ...
+ struct _ {std::string s;boost::int32_t i;};
+ char __ [32-sizeof(_)];
};
std::ostream & operator<<(std::ostream & os, ComplexAnnotation const & v)
BarPacket::createAfter(packet);
ComplexAnnotation & ca (packet.annotation<ComplexAnnotation>());
+
+ BOOST_CHECK_EQUAL( ca.s, "empty" );
+ BOOST_CHECK_EQUAL( ca.i, -1 );
+
ca.s = "dead beef";
ca.i = 0x12345678;
SENF_CHECK_NO_THROW( packet.annotation<IntAnnotation>().value = 0xDEADBEEF );
BOOST_CHECK( Reg::lookup<ComplexAnnotation>() < 0 );
BOOST_CHECK( Reg::lookup<ComplexEmptyAnnotation>() < 0 );
-#ifdef SENF_DEBUG
std::stringstream ss;
-
senf::dumpPacketAnnotationRegistry(ss);
BOOST_CHECK_EQUAL(
ss.str(),
"SENF_PACKET_ANNOTATION_SLOTS = 8\n"
"SENF_PACKET_ANNOTATION_SLOTSIZE = 16\n"
- "SLOT TYPE COMPLEX SIZE\n"
- " (anonymous namespace)::ComplexEmptyAnnotation yes 1\n"
- " (anonymous namespace)::ComplexAnnotation yes 8\n"
- " (anonymous namespace)::LargeAnnotation no 32\n"
- " 0 (anonymous namespace)::IntAnnotation no 4\n" );
-#endif
+ "TYPE FAST COMPLEX SIZE\n"
+ "(anonymous namespace)::ComplexAnnotation no yes 32\n"
+ "(anonymous namespace)::ComplexEmptyAnnotation no yes 1\n"
+ "(anonymous namespace)::IntAnnotation yes no 4\n"
+ "(anonymous namespace)::LargeAnnotation no no 32\n" );
}
#ifdef COMPILE_CHECK