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 Jack unit tests */
31 //#include "Jack.test.hh"
32 //#include "Jack.test.ih"
36 #include "DebugModules.hh"
38 #include <senf/Utils/auto_unit_test.hh>
39 #include <boost/test/test_tools.hpp>
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 class ActiveDummyForward
47 : public senf::ppi::module::Module
49 SENF_PPI_MODULE(ActiveDummyForward);
51 senf::ppi::connector::ActiveInput<> input;
52 senf::ppi::connector::PassiveOutput<> output;
54 ActiveDummyForward() : n (0)
55 { route(input, output); output.onRequest(&ActiveDummyForward::request); }
61 { ++n; output(input()); }
64 class PassiveDummyForward
65 : public senf::ppi::module::Module
67 SENF_PPI_MODULE(PassiveDummyForward);
69 senf::ppi::connector::PassiveInput<> input;
70 senf::ppi::connector::ActiveOutput<> output;
72 PassiveDummyForward() : n (0)
73 { route(input, output); input.onRequest(&PassiveDummyForward::request); }
79 { ++n; output(input()); }
84 senf::ppi::connector::ActiveInputJack<> input;
85 senf::ppi::connector::PassiveOutputJack<> output;
88 : input (forward1.input), output (forward1.output) {}
92 input.reset(forward2.input);
93 output.reset(forward2.output);
96 ActiveDummyForward forward1;
97 ActiveDummyForward forward2;
102 senf::ppi::connector::PassiveInputJack<> input;
103 senf::ppi::connector::ActiveOutputJack<> output;
106 : input (forward1.input), output (forward1.output) {}
110 input.reset(forward2.input);
111 output.reset(forward2.output);
114 PassiveDummyForward forward1;
115 PassiveDummyForward forward2;
120 SENF_AUTO_UNIT_TEST(jacks)
124 senf::ppi::module::debug::PassiveSource source;
125 senf::ppi::module::debug::ActiveSink sink;
127 senf::ppi::connect(source, group);
128 senf::ppi::connect(group, sink);
133 senf::Packet p (senf::DataPacket::create());
136 BOOST_CHECK(p == sink.request());
143 senf::Packet p (senf::DataPacket::create());
146 BOOST_CHECK(p == sink.request());
149 BOOST_CHECK_EQUAL( group.forward1.n, 1u );
150 BOOST_CHECK_EQUAL( group.forward2.n, 1u );
155 senf::ppi::module::debug::ActiveSource source;
156 senf::ppi::module::debug::PassiveSink sink;
158 senf::ppi::connect(source, group);
159 senf::ppi::connect(group, sink);
164 senf::Packet p (senf::DataPacket::create());
167 BOOST_CHECK(p == sink.pop_front());
174 senf::Packet p (senf::DataPacket::create());
177 BOOST_CHECK(p == sink.pop_front());
180 BOOST_CHECK_EQUAL( group.forward1.n, 1u );
181 BOOST_CHECK_EQUAL( group.forward2.n, 1u );
185 //-/////////////////////////////////////////////////////////////////////////////////////////////////
192 // comment-column: 40
193 // c-file-style: "senf"
194 // indent-tabs-mode: nil
195 // ispell-local-dictionary: "american"
196 // compile-command: "scons -u test"