From: pug Date: Thu, 10 Dec 2009 12:55:41 +0000 (+0000) Subject: Added missing Unittest for STL-Predicate in genericTLVs X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=575b110bed5e4f051b197bed884fb8999822d14e;p=senf.git Added missing Unittest for STL-Predicate in genericTLVs git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1538 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/GenericTLV.test.cc b/senf/Packets/GenericTLV.test.cc index 6b93252..b80d3fe 100644 --- a/senf/Packets/GenericTLV.test.cc +++ b/senf/Packets/GenericTLV.test.cc @@ -25,6 +25,7 @@ // Custom includes #include "GenericTLV.hh" +#include #include #include @@ -73,6 +74,29 @@ namespace { << " value: " << senf::format::dumpint(myValue()) << "\n"; } }; + + struct MyConcrete2TLVParser + : public MyTLVParserBase + { + # include SENF_PARSER() + SENF_PARSER_INHERIT ( MyTLVParserBase ); + SENF_PARSER_FIELD ( myValue, senf::UInt32Parser ); + SENF_PARSER_FINALIZE ( MyConcrete2TLVParser ); + + SENF_PARSER_INIT() { + type() = typeId; + length_() = 4; + } + static type_t::value_type const typeId = 0x47; + + void dump(std::ostream & os) const { + boost::io::ios_all_saver ias(os); + os << " MyConcreteTLVParser\n" + << " type: " << senf::format::dumpint(type()) << "\n" + << " length: " << senf::format::dumpint(length()) << "\n" + << " value: " << senf::format::dumpint(myValue()) << "\n"; + } + }; class MyTestPacketParser : public senf::PacketParserBase @@ -172,6 +196,27 @@ BOOST_AUTO_UNIT_TEST(GenericTLV_registry) BOOST_CHECK_EQUAL( ss.str().substr(0,21), " MyConcreteTLVParser" ); } +BOOST_AUTO_UNIT_TEST(GenericTLV_predicate) +{ + MyTestPacket p ( MyTestPacket::create() ); + MyTestPacket::Parser::tlv_list_t::container tlvContainer (p->tlv_list() ); + MyConcreteTLVParser conreteTLVParser ( + tlvContainer.push_back_space().init()); + conreteTLVParser.myValue() << 0xffff; + MyConcrete2TLVParser conreteTLVParser2 ( + tlvContainer.push_back_space().init()); + conreteTLVParser2.myValue() << 0xdddd; + p.finalizeThis(); + +// typedef senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optContainer_t; +// optContainer_t optC (p->tlv_list() ); + + MyTestPacket::Parser::tlv_list_t::container testTlvContainer (p->tlv_list() ); + MyTestPacket::Parser::tlv_list_t::container::iterator it = std::find_if ( + testTlvContainer.begin(), testTlvContainer.end(), + senf::detail::Predicate< senf::GenericTLVParserBase, MyConcreteTLVParser>() ); + BOOST_CHECK( it->is()) ; +} ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_