4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief DebubgModules unit tests */
31 //#include "DebubgModules.test.hh"
32 //#include "DebubgModules.test.ih"
38 #define SENF_LOG_CONF (( (senf)(log)(Debug), (_), VERBOSE ))
40 #include <senf/Packets/Packets.hh>
41 #include "DebugModules.hh"
44 #include <senf/Utils/auto_unit_test.hh>
45 #include <boost/test/test_tools.hpp>
48 //-/////////////////////////////////////////////////////////////////////////////////////////////////
50 namespace debug = senf::ppi::module::debug;
51 namespace ppi = senf::ppi;
53 SENF_AUTO_UNIT_TEST(debugModules)
56 debug::ActiveSource source;
57 debug::PassiveSink sink;
59 ppi::connect(source, sink);
62 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
63 senf::Packet p (senf::DataPacket::create(data));
65 BOOST_CHECK( ! sink.input.throttled() );
69 BOOST_CHECK( ! sink.input.throttled() );
70 BOOST_CHECK_EQUAL( sink.size(), 1u );
71 BOOST_CHECK( ! sink.empty() );
73 debug::PassiveSink::size_type(std::distance(sink.begin(),sink.end())),
75 BOOST_CHECK( *sink.begin() == p );
76 BOOST_CHECK( sink.front() == p );
80 BOOST_CHECK( ! sink.front() );
81 BOOST_CHECK( sink.empty() );
85 debug::PassiveSource source;
86 debug::ActiveSink sink;
88 ppi::connect(source, sink);
91 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
92 senf::Packet p (senf::DataPacket::create(data));
96 BOOST_CHECK_EQUAL( source.size(), 1u );
97 BOOST_CHECK_EQUAL( sink.request(), p );
98 BOOST_CHECK_EQUAL( source.size(), 0u );
99 BOOST_CHECK( source.empty() );
103 SENF_AUTO_UNIT_TEST(activeFeederSource)
105 debug::ActiveFeederSource source;
106 debug::PassiveSink sink;
108 ppi::connect(source,sink);
109 source.submit(senf::DataPacket::create());
112 BOOST_CHECK( source.empty() );
113 BOOST_CHECK_EQUAL( source.size(), 0u );
114 BOOST_CHECK_EQUAL( sink.size(), 1u );
117 SENF_AUTO_UNIT_TEST(activeFeederSink)
119 debug::PassiveSource source;
120 debug::ActiveFeederSink sink;
122 ppi::connect(source,sink);
123 source.submit(senf::DataPacket::create());
126 BOOST_CHECK( ! sink.empty() );
127 BOOST_CHECK_EQUAL( sink.size(), 1u );
128 BOOST_CHECK_EQUAL( debug::ActiveFeederSink::size_type(std::distance(sink.begin(), sink.end())),
130 BOOST_CHECK( sink.front().data().empty() );
131 BOOST_CHECK( sink.pop_front().data().empty() );
132 BOOST_CHECK( sink.empty() );
133 BOOST_CHECK( source.empty() );
136 SENF_AUTO_UNIT_TEST(logSink)
138 senf::log::StringTarget logTarget;
139 logTarget.route<senf::log::Debug,senf::log::VERBOSE>();
141 debug::ActiveFeederSource source;
142 debug::Logger<> logger ("Prefix text");
144 ppi::connect(source,logger);
145 senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
146 source.submit( senf::DataPacket::create(data) );
149 BOOST_CHECK( ! logTarget.str().empty() );
152 //-/////////////////////////////////////////////////////////////////////////////////////////////////
159 // comment-column: 40
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u test"