X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FGenericTLV.test.cc;h=6b93252cbd210406434562385e4788772c7166f9;hb=8bab2fbb2a8272199adc7034ddcd43ecdeb942a9;hp=d35523cdc696bdd72eb3a81955d8ade38c97063e;hpb=cf48e83de9d4793ca5bd67d1e5acdb5b20968638;p=senf.git diff --git a/senf/Packets/GenericTLV.test.cc b/senf/Packets/GenericTLV.test.cc index d35523c..6b93252 100644 --- a/senf/Packets/GenericTLV.test.cc +++ b/senf/Packets/GenericTLV.test.cc @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2008 +// Copyright (C) 2009 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY -// @AUTHOR@ +// Thorsten Horstmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ // Custom includes #include "GenericTLV.hh" -#include #include #include @@ -41,6 +40,8 @@ namespace { SENF_PARSER_FIELD ( type, senf::UInt8Parser ); SENF_PARSER_FIELD_RO ( length, senf::UInt8Parser ); SENF_PARSER_FINALIZE ( MyTLVParserBase ); + + typedef senf::GenericTLVParserRegistry Registry; }; struct MyGenericTLVParser @@ -62,17 +63,16 @@ namespace { type() = typeId; length_() = 4; } - static type_t::value_type const typeId; + static type_t::value_type const typeId = 0x42; 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"; + os << " MyConcreteTLVParser\n" + << " type: " << senf::format::dumpint(type()) << "\n" + << " length: " << senf::format::dumpint(length()) << "\n" + << " value: " << senf::format::dumpint(myValue()) << "\n"; } }; - MyConcreteTLVParser::type_t::value_type const MyConcreteTLVParser::typeId = 0x42; class MyTestPacketParser : public senf::PacketParserBase @@ -159,17 +159,17 @@ BOOST_AUTO_UNIT_TEST(GenericTLV_registry) conreteTLVParser.myValue() << 0xffff; p.finalizeThis(); - typedef senf::GenericTLVParserRegistry MyTLVParserRegistry; - std::stringstream ss; - MyTLVParserRegistry::instance().dump(ss, *tlvContainer.begin()); - BOOST_CHECK_EQUAL( ss.str().substr(0,56), "GenericTLVParser<(anonymous namespace)::MyTLVParserBase>" ); + (*tlvContainer.begin()).dump( ss); + BOOST_CHECK_EQUAL( ss.str().substr(0,58), + " GenericTLVParser<(anonymous namespace)::MyTLVParserBase>" ); - MyTLVParserRegistry::instance().registerParser(); + senf::GenericTLVParserRegistry::instance() + .registerParser(); ss.str(""); ss.clear(); - MyTLVParserRegistry::instance().dump(ss, *tlvContainer.begin()); - BOOST_CHECK_EQUAL( ss.str().substr(0,19), "MyConcreteTLVParser" ); + (*tlvContainer.begin()).dump( ss); + BOOST_CHECK_EQUAL( ss.str().substr(0,21), " MyConcreteTLVParser" ); }