fd95c32d36fe0efea84e9a0acd33e0c7a1eec85c
[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.output, sink.input);
51         
52         senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
53         senf::Packet p (senf::DataPacket::create(data));
54
55         source.submit(p);
56         
57         BOOST_CHECK_EQUAL( sink.size(), 1u );
58         BOOST_CHECK( ! sink.empty() );
59         BOOST_CHECK_EQUAL( 
60             debug::PassivePacketSink::size_type(std::distance(sink.begin(),sink.end())),
61             sink.size() );
62         BOOST_CHECK( *sink.begin() == p );
63         BOOST_CHECK( sink.back() == p );
64
65         sink.clear();
66
67         BOOST_CHECK( ! sink.back() );
68         BOOST_CHECK( sink.empty() );
69     }
70
71     {
72         debug::PassivePacketSource source;
73         debug::ActivePacketSink sink;
74
75         ppi::connect(source.output, sink.input);
76
77         senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
78         senf::Packet p (senf::DataPacket::create(data));
79
80         source.submit(p);
81         
82         BOOST_CHECK_EQUAL( source.size(), 1u );
83         BOOST_CHECK_EQUAL( sink.request(), p );
84         BOOST_CHECK_EQUAL( source.size(), 0u );
85         BOOST_CHECK( source.empty() );
86     }
87 }
88
89 ///////////////////////////////cc.e////////////////////////////////////////
90 #undef prefix_
91
92 \f
93 // Local Variables:
94 // mode: c++
95 // fill-column: 100
96 // comment-column: 40
97 // c-file-style: "senf"
98 // indent-tabs-mode: nil
99 // ispell-local-dictionary: "american"
100 // compile-command: "scons -u test"
101 // End: