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.test unit tests */
26 //#include "DebubgModules.test.hh"
27 //#include "DebubgModules.test.ih"
34 #define SENF_LOG_CONF (( (senf)(log)(Debug), (_), VERBOSE ))
36 #include "../Packets/Packets.hh"
37 #include "DebugModules.hh"
40 #include "../Utils/auto_unit_test.hh"
41 #include <boost/test/test_tools.hpp>
44 ///////////////////////////////cc.p////////////////////////////////////////
46 namespace debug = senf::ppi::module::debug;
47 namespace ppi = senf::ppi;
49 BOOST_AUTO_UNIT_TEST(debugModules)
52 debug::ActiveSource source;
53 debug::PassiveSink sink;
55 ppi::connect(source, sink);
58 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
59 senf::Packet p (senf::DataPacket::create(data));
61 BOOST_CHECK( ! sink.input.throttled() );
65 BOOST_CHECK( ! sink.input.throttled() );
66 BOOST_CHECK_EQUAL( sink.size(), 1u );
67 BOOST_CHECK( ! sink.empty() );
69 debug::PassiveSink::size_type(std::distance(sink.begin(),sink.end())),
71 BOOST_CHECK( *sink.begin() == p );
72 BOOST_CHECK( sink.front() == p );
76 BOOST_CHECK( ! sink.front() );
77 BOOST_CHECK( sink.empty() );
81 debug::PassiveSource source;
82 debug::ActiveSink sink;
84 ppi::connect(source, sink);
87 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
88 senf::Packet p (senf::DataPacket::create(data));
92 BOOST_CHECK_EQUAL( source.size(), 1u );
93 BOOST_CHECK_EQUAL( sink.request(), p );
94 BOOST_CHECK_EQUAL( source.size(), 0u );
95 BOOST_CHECK( source.empty() );
99 BOOST_AUTO_UNIT_TEST(activeFeederSource)
101 debug::ActiveFeederSource source;
102 debug::PassiveSink sink;
104 ppi::connect(source,sink);
105 source.submit(senf::DataPacket::create());
108 BOOST_CHECK( source.empty() );
109 BOOST_CHECK_EQUAL( source.size(), 0u );
110 BOOST_CHECK_EQUAL( sink.size(), 1u );
113 BOOST_AUTO_UNIT_TEST(activeFeederSink)
115 debug::PassiveSource source;
116 debug::ActiveFeederSink sink;
118 ppi::connect(source,sink);
119 source.submit(senf::DataPacket::create());
122 BOOST_CHECK( ! sink.empty() );
123 BOOST_CHECK_EQUAL( sink.size(), 1u );
124 BOOST_CHECK_EQUAL( debug::ActiveFeederSink::size_type(std::distance(sink.begin(), sink.end())),
126 BOOST_CHECK( sink.front().data().empty() );
127 BOOST_CHECK( sink.pop_front().data().empty() );
128 BOOST_CHECK( sink.empty() );
129 BOOST_CHECK( source.empty() );
132 BOOST_AUTO_UNIT_TEST(logSink)
134 senf::log::StringTarget logTarget;
135 logTarget.route<senf::log::Debug,senf::log::VERBOSE>();
137 debug::ActiveFeederSource source;
138 debug::LogSink<> sink;
140 ppi::connect(source,sink);
141 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
142 source.submit( senf::DataPacket::create(data) );
145 BOOST_CHECK( ! logTarget.str().empty() );
148 ///////////////////////////////cc.e////////////////////////////////////////
155 // comment-column: 40
156 // c-file-style: "senf"
157 // indent-tabs-mode: nil
158 // ispell-local-dictionary: "american"
159 // compile-command: "scons -u test"