4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.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.
24 \brief DebubgModules unit tests */
26 //#include "DebubgModules.test.hh"
27 //#include "DebubgModules.test.ih"
33 #define SENF_LOG_CONF (( (senf)(log)(Debug), (_), VERBOSE ))
35 #include "../Packets/Packets.hh"
36 #include "DebugModules.hh"
39 #include "../Utils/auto_unit_test.hh"
40 #include <boost/test/test_tools.hpp>
43 ///////////////////////////////cc.p////////////////////////////////////////
45 namespace debug = senf::ppi::module::debug;
46 namespace ppi = senf::ppi;
48 BOOST_AUTO_UNIT_TEST(debugModules)
51 debug::ActiveSource source;
52 debug::PassiveSink sink;
54 ppi::connect(source, sink);
57 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
58 senf::Packet p (senf::DataPacket::create(data));
60 BOOST_CHECK( ! sink.input.throttled() );
64 BOOST_CHECK( ! sink.input.throttled() );
65 BOOST_CHECK_EQUAL( sink.size(), 1u );
66 BOOST_CHECK( ! sink.empty() );
68 debug::PassiveSink::size_type(std::distance(sink.begin(),sink.end())),
70 BOOST_CHECK( *sink.begin() == p );
71 BOOST_CHECK( sink.front() == p );
75 BOOST_CHECK( ! sink.front() );
76 BOOST_CHECK( sink.empty() );
80 debug::PassiveSource source;
81 debug::ActiveSink sink;
83 ppi::connect(source, sink);
86 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
87 senf::Packet p (senf::DataPacket::create(data));
91 BOOST_CHECK_EQUAL( source.size(), 1u );
92 BOOST_CHECK_EQUAL( sink.request(), p );
93 BOOST_CHECK_EQUAL( source.size(), 0u );
94 BOOST_CHECK( source.empty() );
98 BOOST_AUTO_UNIT_TEST(activeFeederSource)
100 debug::ActiveFeederSource source;
101 debug::PassiveSink sink;
103 ppi::connect(source,sink);
104 source.submit(senf::DataPacket::create());
107 BOOST_CHECK( source.empty() );
108 BOOST_CHECK_EQUAL( source.size(), 0u );
109 BOOST_CHECK_EQUAL( sink.size(), 1u );
112 BOOST_AUTO_UNIT_TEST(activeFeederSink)
114 debug::PassiveSource source;
115 debug::ActiveFeederSink sink;
117 ppi::connect(source,sink);
118 source.submit(senf::DataPacket::create());
121 BOOST_CHECK( ! sink.empty() );
122 BOOST_CHECK_EQUAL( sink.size(), 1u );
123 BOOST_CHECK_EQUAL( debug::ActiveFeederSink::size_type(std::distance(sink.begin(), sink.end())),
125 BOOST_CHECK( sink.front().data().empty() );
126 BOOST_CHECK( sink.pop_front().data().empty() );
127 BOOST_CHECK( sink.empty() );
128 BOOST_CHECK( source.empty() );
131 BOOST_AUTO_UNIT_TEST(logSink)
133 senf::log::StringTarget logTarget;
134 logTarget.route<senf::log::Debug,senf::log::VERBOSE>();
136 debug::ActiveFeederSource source;
137 debug::Logger<> logger ("Prefix text");
139 ppi::connect(source,logger);
140 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
141 source.submit( senf::DataPacket::create(data) );
144 BOOST_CHECK( ! logTarget.str().empty() );
147 ///////////////////////////////cc.e////////////////////////////////////////
154 // comment-column: 40
155 // c-file-style: "senf"
156 // indent-tabs-mode: nil
157 // ispell-local-dictionary: "american"
158 // compile-command: "scons -u test"