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"
32 #include <senf/Utils/auto_unit_test.hh>
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
40 class ActiveDummyForward
41 : public senf::ppi::module::Module
43 SENF_PPI_MODULE(ActiveDummyForward);
45 senf::ppi::connector::ActiveInput<> input;
46 senf::ppi::connector::PassiveOutput<> output;
48 ActiveDummyForward() : n (0)
49 { route(input, output); output.onRequest(&ActiveDummyForward::request); }
55 { ++n; output(input()); }
58 class PassiveDummyForward
59 : public senf::ppi::module::Module
61 SENF_PPI_MODULE(PassiveDummyForward);
63 senf::ppi::connector::PassiveInput<> input;
64 senf::ppi::connector::ActiveOutput<> output;
66 PassiveDummyForward() : n (0)
67 { route(input, output); input.onRequest(&PassiveDummyForward::request); }
73 { ++n; output(input()); }
78 senf::ppi::connector::ActiveInputJack<> input;
79 senf::ppi::connector::PassiveOutputJack<> output;
82 : input (forward1.input), output (forward1.output) {}
86 input.reset(forward2.input);
87 output.reset(forward2.output);
90 ActiveDummyForward forward1;
91 ActiveDummyForward forward2;
96 senf::ppi::connector::PassiveInputJack<> input;
97 senf::ppi::connector::ActiveOutputJack<> output;
100 : input (forward1.input), output (forward1.output) {}
104 input.reset(forward2.input);
105 output.reset(forward2.output);
108 PassiveDummyForward forward1;
109 PassiveDummyForward forward2;
114 BOOST_AUTO_UNIT_TEST(jacks)
118 senf::ppi::module::debug::PassiveSource source;
119 senf::ppi::module::debug::ActiveSink sink;
121 senf::ppi::connect(source, group);
122 senf::ppi::connect(group, sink);
127 senf::Packet p (senf::DataPacket::create());
130 BOOST_CHECK(p == sink.request());
137 senf::Packet p (senf::DataPacket::create());
140 BOOST_CHECK(p == sink.request());
143 BOOST_CHECK_EQUAL( group.forward1.n, 1u );
144 BOOST_CHECK_EQUAL( group.forward2.n, 1u );
149 senf::ppi::module::debug::ActiveSource source;
150 senf::ppi::module::debug::PassiveSink sink;
152 senf::ppi::connect(source, group);
153 senf::ppi::connect(group, sink);
158 senf::Packet p (senf::DataPacket::create());
161 BOOST_CHECK(p == sink.pop_front());
168 senf::Packet p (senf::DataPacket::create());
171 BOOST_CHECK(p == sink.pop_front());
174 BOOST_CHECK_EQUAL( group.forward1.n, 1u );
175 BOOST_CHECK_EQUAL( group.forward2.n, 1u );
179 ///////////////////////////////cc.e////////////////////////////////////////
186 // comment-column: 40
187 // c-file-style: "senf"
188 // indent-tabs-mode: nil
189 // ispell-local-dictionary: "american"
190 // compile-command: "scons -u test"