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 #include "../Packets/Packets.hh"
40 #include "DebugModules.hh"
43 #include <boost/test/auto_unit_test.hpp>
44 #include <boost/test/test_tools.hpp>
47 ///////////////////////////////cc.p////////////////////////////////////////
49 namespace debug = senf::ppi::module::debug;
50 namespace ppi = senf::ppi;
52 BOOST_AUTO_UNIT_TEST(debugModules)
55 debug::ActiveSource source;
56 debug::PassiveSink sink;
58 ppi::connect(source, sink);
61 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
62 senf::Packet p (senf::DataPacket::create(data));
64 BOOST_CHECK( ! sink.input.throttled() );
68 BOOST_CHECK( ! sink.input.throttled() );
69 BOOST_CHECK_EQUAL( sink.size(), 1u );
70 BOOST_CHECK( ! sink.empty() );
72 debug::PassiveSink::size_type(std::distance(sink.begin(),sink.end())),
74 BOOST_CHECK( *sink.begin() == p );
75 BOOST_CHECK( sink.front() == p );
79 BOOST_CHECK( ! sink.front() );
80 BOOST_CHECK( sink.empty() );
84 debug::PassiveSource source;
85 debug::ActiveSink sink;
87 ppi::connect(source, sink);
90 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
91 senf::Packet p (senf::DataPacket::create(data));
95 BOOST_CHECK_EQUAL( source.size(), 1u );
96 BOOST_CHECK_EQUAL( sink.request(), p );
97 BOOST_CHECK_EQUAL( source.size(), 0u );
98 BOOST_CHECK( source.empty() );
102 BOOST_AUTO_UNIT_TEST(activeFeederSource)
104 debug::ActiveFeederSource source;
105 debug::PassiveSink sink;
107 ppi::connect(source,sink);
108 source.submit(senf::DataPacket::create());
111 BOOST_CHECK( source.empty() );
112 BOOST_CHECK_EQUAL( source.size(), 0u );
113 BOOST_CHECK_EQUAL( sink.size(), 1u );
116 BOOST_AUTO_UNIT_TEST(activeFeederSink)
118 debug::PassiveSource source;
119 debug::ActiveFeederSink sink;
121 ppi::connect(source,sink);
122 source.submit(senf::DataPacket::create());
125 BOOST_CHECK( ! sink.empty() );
126 BOOST_CHECK_EQUAL( sink.size(), 1u );
127 BOOST_CHECK_EQUAL( debug::ActiveFeederSink::size_type(std::distance(sink.begin(), sink.end())),
129 BOOST_CHECK( sink.front().data().empty() );
130 BOOST_CHECK( sink.pop_front().data().empty() );
131 BOOST_CHECK( sink.empty() );
132 BOOST_CHECK( source.empty() );
135 BOOST_AUTO_UNIT_TEST(logSink)
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_EQUAL( logstream.str(),
146 " 0000 13 24 35 .$5\n\n" );
149 ///////////////////////////////cc.e////////////////////////////////////////
156 // comment-column: 40
157 // c-file-style: "senf"
158 // indent-tabs-mode: nil
159 // ispell-local-dictionary: "american"
160 // compile-command: "scons -u test"