4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
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_STREAM logstream
36 std::stringstream logstream;
39 #define SENF_LOG_CONF (( (senf)(log)(Debug), (_), VERBOSE ))
41 #include "../Packets/Packets.hh"
42 #include "DebugModules.hh"
45 #include <boost/test/auto_unit_test.hpp>
46 #include <boost/test/test_tools.hpp>
49 ///////////////////////////////cc.p////////////////////////////////////////
51 namespace debug = senf::ppi::module::debug;
52 namespace ppi = senf::ppi;
54 BOOST_AUTO_UNIT_TEST(debugModules)
57 debug::ActiveSource source;
58 debug::PassiveSink sink;
60 ppi::connect(source, sink);
63 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
64 senf::Packet p (senf::DataPacket::create(data));
66 BOOST_CHECK( ! sink.input.throttled() );
70 BOOST_CHECK( ! sink.input.throttled() );
71 BOOST_CHECK_EQUAL( sink.size(), 1u );
72 BOOST_CHECK( ! sink.empty() );
74 debug::PassiveSink::size_type(std::distance(sink.begin(),sink.end())),
76 BOOST_CHECK( *sink.begin() == p );
77 BOOST_CHECK( sink.front() == p );
81 BOOST_CHECK( ! sink.front() );
82 BOOST_CHECK( sink.empty() );
86 debug::PassiveSource source;
87 debug::ActiveSink sink;
89 ppi::connect(source, sink);
92 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
93 senf::Packet p (senf::DataPacket::create(data));
97 BOOST_CHECK_EQUAL( source.size(), 1u );
98 BOOST_CHECK_EQUAL( sink.request(), p );
99 BOOST_CHECK_EQUAL( source.size(), 0u );
100 BOOST_CHECK( source.empty() );
104 BOOST_AUTO_UNIT_TEST(activeFeederSource)
106 debug::ActiveFeederSource source;
107 debug::PassiveSink sink;
109 ppi::connect(source,sink);
110 source.submit(senf::DataPacket::create());
113 BOOST_CHECK( source.empty() );
114 BOOST_CHECK_EQUAL( source.size(), 0u );
115 BOOST_CHECK_EQUAL( sink.size(), 1u );
118 BOOST_AUTO_UNIT_TEST(activeFeederSink)
120 debug::PassiveSource source;
121 debug::ActiveFeederSink sink;
123 ppi::connect(source,sink);
124 source.submit(senf::DataPacket::create());
127 BOOST_CHECK( ! sink.empty() );
128 BOOST_CHECK_EQUAL( sink.size(), 1u );
129 BOOST_CHECK_EQUAL( debug::ActiveFeederSink::size_type(std::distance(sink.begin(), sink.end())),
131 BOOST_CHECK( sink.front().data().empty() );
132 BOOST_CHECK( sink.pop_front().data().empty() );
133 BOOST_CHECK( sink.empty() );
134 BOOST_CHECK( source.empty() );
137 BOOST_AUTO_UNIT_TEST(logSink)
139 debug::ActiveFeederSource source;
140 debug::LogSink<> sink;
142 ppi::connect(source,sink);
143 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
144 source.submit( senf::DataPacket::create(data) );
147 BOOST_CHECK_EQUAL( logstream.str(),
148 " 0000 13 24 35 .$5\n\n" );
151 ///////////////////////////////cc.e////////////////////////////////////////
158 // comment-column: 40
159 // c-file-style: "senf"
160 // indent-tabs-mode: nil
161 // ispell-local-dictionary: "american"
162 // compile-command: "scons -u test"