Socket/Protocols/Raw: EUI64 documentation
[senf.git] / PPI / Jack.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2009 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief Jack unit tests */
25
26 //#include "Jack.test.hh"
27 //#include "Jack.test.ih"
28
29 // Custom includes
30 #include "PPI.hh"
31
32 #include "../Utils/auto_unit_test.hh"
33 #include <boost/test/test_tools.hpp>
34
35 #define prefix_
36 ///////////////////////////////cc.p////////////////////////////////////////
37
38 namespace {
39
40     class ActiveDummyForward 
41         : public senf::ppi::module::Module
42     {
43         SENF_PPI_MODULE(ActiveDummyForward);
44     public:
45         senf::ppi::connector::ActiveInput<> input;
46         senf::ppi::connector::PassiveOutput<> output;
47
48         ActiveDummyForward()
49             { route(input, output); output.onRequest(&ActiveDummyForward::request); }
50
51     private:
52         void request()
53             { output(input()); }
54     };
55
56     class PassiveDummyForward 
57         : public senf::ppi::module::Module
58     {
59         SENF_PPI_MODULE(PassiveDummyForward);
60     public:
61         senf::ppi::connector::PassiveInput<> input;
62         senf::ppi::connector::ActiveOutput<> output;
63
64         PassiveDummyForward()
65             { route(input, output); input.onRequest(&PassiveDummyForward::request); }
66
67     private:
68         void request()
69             { output(input()); }
70     };
71
72     class ActiveGroup
73     {
74     public:
75         senf::ppi::connector::ActiveInputJack<> input;
76         senf::ppi::connector::PassiveOutputJack<> output;
77
78         ActiveGroup()
79             : input (forward.input), output (forward.output) {}
80
81     private:
82         ActiveDummyForward forward;
83     };
84
85     class PassiveGroup
86     {
87     public:
88         senf::ppi::connector::PassiveInputJack<> input;
89         senf::ppi::connector::ActiveOutputJack<> output;
90
91         PassiveGroup()
92             : input (forward.input), output (forward.output) {}
93         
94     private:
95         PassiveDummyForward forward;
96     };
97
98 }
99
100 BOOST_AUTO_UNIT_TEST(jacks)
101 {
102     {
103         ActiveGroup group;
104         senf::ppi::module::debug::PassiveSource source;
105         senf::ppi::module::debug::ActiveSink sink;
106
107         senf::ppi::connect(source, group);
108         senf::ppi::connect(group, sink);
109         
110         senf::ppi::init();
111         
112         senf::Packet p (senf::DataPacket::create());
113         source.submit(p);
114         
115         BOOST_CHECK(p == sink.request());
116     }
117      
118     {
119         PassiveGroup group;
120         senf::ppi::module::debug::ActiveSource source;
121         senf::ppi::module::debug::PassiveSink sink;
122
123         senf::ppi::connect(source, group);
124         senf::ppi::connect(group, sink);
125
126         senf::ppi::init();
127
128         senf::Packet p (senf::DataPacket::create());
129         source.submit(p);
130
131         BOOST_CHECK(p == sink.front());
132     }
133 }
134
135 ///////////////////////////////cc.e////////////////////////////////////////
136 #undef prefix_
137
138 \f
139 // Local Variables:
140 // mode: c++
141 // fill-column: 100
142 // comment-column: 40
143 // c-file-style: "senf"
144 // indent-tabs-mode: nil
145 // ispell-local-dictionary: "american"
146 // compile-command: "scons -u test"
147 // End: