4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 //#include "PacketRegistry.test.hh"
26 //#include "PacketRegistry.test.ih"
30 #include "PacketRegistry.hh"
31 #include "PacketType.hh"
32 #include "ParseInt.hh"
34 #include <boost/test/auto_unit_test.hpp>
35 #include <boost/test/test_tools.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
45 typedef unsigned key_t;
49 typedef std::string key_t;
52 struct FooPacketType : public PacketTypeBase {};
53 struct BarPacketType : public PacketTypeBase {};
54 struct OtherPacketType : public PacketTypeBase {};
57 PacketRegistry<StringTag>::RegistrationProxy<FooPacketType> registerFoo ("foo");
58 PacketRegistry<StringTag>::RegistrationProxy<BarPacketType> registerBar ("bar");
63 BOOST_AUTO_UNIT_TEST(packetRegistry_test)
65 PacketRegistry<BaseTag>::registerPacket<FooPacketType>(1u);
66 PacketRegistry<BaseTag>::registerPacket<BarPacketType>(2u);
68 BOOST_CHECK_EQUAL( PacketRegistry<BaseTag>::key<FooPacketType>(), 1u );
69 BOOST_CHECK_EQUAL( PacketRegistry<BaseTag>::key<BarPacketType>(), 2u );
70 BOOST_CHECK_THROW( PacketRegistry<BaseTag>::key<OtherPacketType>(),
71 PacketTypeNotRegisteredException );
73 BOOST_CHECK_EQUAL( PacketRegistry<StringTag>::key<FooPacketType>(), "foo" );
74 BOOST_CHECK( ! PacketRegistry<StringTag>::lookup("blub", senf::nothrow) );
75 BOOST_CHECK( PacketRegistry<BaseTag>::lookup(1u, senf::nothrow) );
79 ///////////////////////////////cc.e////////////////////////////////////////
86 // c-file-style: "senf"
87 // indent-tabs-mode: nil
88 // ispell-local-dictionary: "american"
89 // compile-command: "scons -u test"