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 Jack unit tests */
26 //#include "Jack.test.hh"
27 //#include "Jack.test.ih"
31 #include "DebugModules.hh"
33 #include <senf/Utils/auto_unit_test.hh>
34 #include <boost/test/test_tools.hpp>
37 ///////////////////////////////cc.p////////////////////////////////////////
41 class ActiveDummyForward
42 : public senf::ppi::module::Module
44 SENF_PPI_MODULE(ActiveDummyForward);
46 senf::ppi::connector::ActiveInput<> input;
47 senf::ppi::connector::PassiveOutput<> output;
49 ActiveDummyForward() : n (0)
50 { route(input, output); output.onRequest(&ActiveDummyForward::request); }
56 { ++n; output(input()); }
59 class PassiveDummyForward
60 : public senf::ppi::module::Module
62 SENF_PPI_MODULE(PassiveDummyForward);
64 senf::ppi::connector::PassiveInput<> input;
65 senf::ppi::connector::ActiveOutput<> output;
67 PassiveDummyForward() : n (0)
68 { route(input, output); input.onRequest(&PassiveDummyForward::request); }
74 { ++n; output(input()); }
79 senf::ppi::connector::ActiveInputJack<> input;
80 senf::ppi::connector::PassiveOutputJack<> output;
83 : input (forward1.input), output (forward1.output) {}
87 input.reset(forward2.input);
88 output.reset(forward2.output);
91 ActiveDummyForward forward1;
92 ActiveDummyForward forward2;
97 senf::ppi::connector::PassiveInputJack<> input;
98 senf::ppi::connector::ActiveOutputJack<> output;
101 : input (forward1.input), output (forward1.output) {}
105 input.reset(forward2.input);
106 output.reset(forward2.output);
109 PassiveDummyForward forward1;
110 PassiveDummyForward forward2;
115 SENF_AUTO_UNIT_TEST(jacks)
119 senf::ppi::module::debug::PassiveSource source;
120 senf::ppi::module::debug::ActiveSink sink;
122 senf::ppi::connect(source, group);
123 senf::ppi::connect(group, sink);
128 senf::Packet p (senf::DataPacket::create());
131 BOOST_CHECK(p == sink.request());
138 senf::Packet p (senf::DataPacket::create());
141 BOOST_CHECK(p == sink.request());
144 BOOST_CHECK_EQUAL( group.forward1.n, 1u );
145 BOOST_CHECK_EQUAL( group.forward2.n, 1u );
150 senf::ppi::module::debug::ActiveSource source;
151 senf::ppi::module::debug::PassiveSink sink;
153 senf::ppi::connect(source, group);
154 senf::ppi::connect(group, sink);
159 senf::Packet p (senf::DataPacket::create());
162 BOOST_CHECK(p == sink.pop_front());
169 senf::Packet p (senf::DataPacket::create());
172 BOOST_CHECK(p == sink.pop_front());
175 BOOST_CHECK_EQUAL( group.forward1.n, 1u );
176 BOOST_CHECK_EQUAL( group.forward2.n, 1u );
180 ///////////////////////////////cc.e////////////////////////////////////////
187 // comment-column: 40
188 // c-file-style: "senf"
189 // indent-tabs-mode: nil
190 // ispell-local-dictionary: "american"
191 // compile-command: "scons -u test"