PPI: Make connect auto-expand module arguments
[senf.git] / PPI / DebugModules.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
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 DebubgModules.test unit tests */
25
26 //#include "DebubgModules.test.hh"
27 //#include "DebubgModules.test.ih"
28
29 // Custom includes
30 #include <algorithm>
31 #include "Packets/Packets.hh"
32 #include "DebugModules.hh"
33 #include "Setup.hh"
34
35 #include <boost/test/auto_unit_test.hpp>
36 #include <boost/test/test_tools.hpp>
37
38 #define prefix_
39 ///////////////////////////////cc.p////////////////////////////////////////
40
41 BOOST_AUTO_UNIT_TEST(debugModules)
42 {
43     namespace debug = senf::ppi::module::debug;
44     namespace ppi = senf::ppi;
45
46     {
47         debug::ActivePacketSource source;
48         debug::PassivePacketSink sink;
49
50         ppi::connect(source, sink);
51         ppi::init();
52     
53         senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
54         senf::Packet p (senf::DataPacket::create(data));
55
56         BOOST_CHECK( ! sink.input.throttled() );
57
58         source.submit(p);
59
60         BOOST_CHECK( ! sink.input.throttled() );
61         BOOST_CHECK_EQUAL( sink.size(), 1u );
62         BOOST_CHECK( ! sink.empty() );
63         BOOST_CHECK_EQUAL( 
64             debug::PassivePacketSink::size_type(std::distance(sink.begin(),sink.end())),
65             sink.size() );
66         BOOST_CHECK( *sink.begin() == p );
67         BOOST_CHECK( sink.front() == p );
68
69         sink.clear();
70
71         BOOST_CHECK( ! sink.front() );
72         BOOST_CHECK( sink.empty() );
73     }
74
75     {
76         debug::PassivePacketSource source;
77         debug::ActivePacketSink sink;
78
79         ppi::connect(source, sink);
80         ppi::init();
81
82         senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
83         senf::Packet p (senf::DataPacket::create(data));
84
85         source.submit(p);
86         
87         BOOST_CHECK_EQUAL( source.size(), 1u );
88         BOOST_CHECK_EQUAL( sink.request(), p );
89         BOOST_CHECK_EQUAL( source.size(), 0u );
90         BOOST_CHECK( source.empty() );
91     }
92 }
93
94 ///////////////////////////////cc.e////////////////////////////////////////
95 #undef prefix_
96
97 \f
98 // Local Variables:
99 // mode: c++
100 // fill-column: 100
101 // comment-column: 40
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"
106 // End: