X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2F80221Bundle%2FTLVPacket.test.cc;h=f96e3b56f1498e76740cfa2dc9d72a7611a1feeb;hb=4891cce7dda76b60f270edfdba16b63d6756c4b0;hp=2e182d1fc6c8a2548e4a42db0b27d8082964286d;hpb=9c3803e6f6a6073a43524940307b7dd7de8b16d9;p=senf.git diff --git a/Packets/80221Bundle/TLVPacket.test.cc b/Packets/80221Bundle/TLVPacket.test.cc index 2e182d1..f96e3b5 100644 --- a/Packets/80221Bundle/TLVPacket.test.cc +++ b/Packets/80221Bundle/TLVPacket.test.cc @@ -31,7 +31,6 @@ #include "../../Utils/auto_unit_test.hh" #include -#include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -39,22 +38,16 @@ using namespace senf; -void check_TLVPacket(GenericTLVPacket &tlvPacket, boost::uint32_t type, boost::uint32_t length) +void check_TLVPacket(GenericTLVPacket &tlvPacket, boost::uint8_t type, boost::uint32_t length) { - BOOST_CHECK_EQUAL( tlvPacket->type(), type ); - BOOST_CHECK_EQUAL( tlvPacket->length(), length ); - - BOOST_CHECK_EQUAL( tlvPacket->value().size(), length); - for (int i=0, j=tlvPacket->value().size(); ivalue()[i], i ); -} - - -BOOST_AUTO_UNIT_TEST(GenericTLVPacket_static) -{ - // check static values: - // number of bytes to allocate for a new GenericTLVPacket should be 2 - BOOST_CHECK_EQUAL( GenericTLVPacket::type::initSize(), 2u ); + BOOST_CHECK_EQUAL( tlvPacket->type(), type ); + BOOST_CHECK_EQUAL( tlvPacket->length(), length ); + BOOST_CHECK_EQUAL( tlvPacket->value().size(), length ); + senf::PacketData::iterator dataIterator (tlvPacket->value().begin()); + for (unsigned i=0; itype() = 42u; - for (uint8_t i=0; i<10; i++) - tlvPacket->value().push_back( i); - tlvPacket.finalizeAll(); + tlvPacket->value( value); + tlvPacket.finalizeThis(); check_TLVPacket( tlvPacket, 42u, 0x0Au ); + + unsigned char data[] = { + 0x2a, // type + 0x0A, // first bit not set, length=10 + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 // value + }; + BOOST_CHECK( equal( tlvPacket.data().begin(), tlvPacket.data().end(), data )); } -/** +#if 0 BOOST_AUTO_UNIT_TEST(TLVPacket_create_packet_with_extended_length) { GenericTLVPacket tlvPacket (GenericTLVPacket::create()); @@ -203,8 +206,7 @@ BOOST_AUTO_UNIT_TEST(TLVFixPacket_create_invalid_packet) test_invalid_TLVFixPacket_creating( UInt24Parser::max_value); } -*/ - +#endif ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_