Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / MPEGDVBBundle / DTCPPacket.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2008
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 DTCPPacket unit tests */
25
26 //#include "DTCPPacket.test.hh"
27 //#include "DTCPPacket.test.ih"
28
29 // Custom includes
30 #include "DTCPPacket.hh"
31 #include <senf/Utils/String.hh>
32
33 #include <senf/Utils/auto_unit_test.hh>
34 #include <boost/test/test_tools.hpp>
35
36 #define prefix_
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 SENF_AUTO_UNIT_TEST(dtcpPacket)
40 {
41     unsigned char data[] = {
42             0x11,                 // versionNumber = 1, command = JOIN
43             5,                    // interval
44             0x0A, 0x0B,           // sequence number
45             0x14,                 // receiveCapable = true, ipVersion = 4
46             23,                   // tunnelProtocol
47             2,                    // fbipCount
48             0x00,
49             101, 102, 103, 104,   // fbip1
50             201, 202, 203, 204    // fbip2
51     };
52
53     senf::DTCPHelloPacket hello (senf::DTCPHelloPacket::create(
54                                      boost::make_iterator_range(data, data+sizeof(data))));
55
56     BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
57                                    hello.data().begin(), hello.data().end() );
58
59     BOOST_CHECK_EQUAL( senf::bytes(hello.parser()), 16u );
60
61     BOOST_CHECK_EQUAL( hello->versionNumber(), 1u );
62     BOOST_CHECK_EQUAL( hello->command(), unsigned(senf::DTCPHelloPacket::Parser::JOIN) );
63     BOOST_CHECK_EQUAL( hello->interval(), 5u );
64     BOOST_CHECK_EQUAL( hello->sequenceNumber(), 0x0A0Bu );
65     BOOST_CHECK_EQUAL( hello->receiveCapableFeed(), true );
66     BOOST_CHECK_EQUAL( hello->ipVersion(), 4u );
67     BOOST_CHECK_EQUAL( hello->tunnelProtocol(), 23u );
68     BOOST_CHECK_EQUAL( hello->fbipCount(), 2u );
69     BOOST_CHECK( hello->has_v4fbipList() );
70     BOOST_CHECK_EQUAL( senf::str(hello->v4fbipList()[0]), "101.102.103.104" );
71     BOOST_CHECK_EQUAL( senf::str(hello->v4fbipList()[1]), "201.202.203.204" );
72
73     std::stringstream ss;
74     hello.dump(ss);
75     BOOST_CHECK_EQUAL( ss.str(),
76                        "DTCP HELLO Packet:\n"
77                        "  version                 : 1\n"
78                        "  command                 : JOIN\n"
79                        "  interval                : 5\n"
80                        "  sequence number         : 2571\n"
81                        "  receive capable feed    : yes\n"
82                        "  ip version              : 4\n"
83                        "  tunnel protocol         : 23\n"
84                        "  number of BDL ips       : 2\n"
85                        "  feed BDL ips:\n"
86                        "    101.102.103.104\n"
87                        "    201.202.203.204\n" );
88
89     senf::DTCPHelloPacket hello2 (senf::DTCPHelloPacket::create());
90
91     SENF_CHECK_NO_THROW( hello2->versionNumber() = 1u );
92     SENF_CHECK_NO_THROW( hello2->command() = senf::DTCPHelloPacket::Parser::JOIN );
93     SENF_CHECK_NO_THROW( hello2->interval() = 5u );
94     SENF_CHECK_NO_THROW( hello2->sequenceNumber() = 0x0A0B );
95     SENF_CHECK_NO_THROW( hello2->receiveCapableFeed() = true );
96     SENF_CHECK_NO_THROW( hello2->tunnelProtocol() = 23u );
97     SENF_CHECK_NO_THROW( hello2->init_v4fbipList() );
98     SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0x65666768u) ) );
99     SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0xC9CACBCCu) ) );
100
101     BOOST_CHECK_EQUAL( senf::bytes(hello2.parser()), 16u );
102     BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
103                                    hello2.data().begin(), hello2.data().end() );
104 }
105
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 #undef prefix_
108
109 \f
110 // Local Variables:
111 // mode: c++
112 // fill-column: 100
113 // comment-column: 40
114 // c-file-style: "senf"
115 // indent-tabs-mode: nil
116 // ispell-local-dictionary: "american"
117 // compile-command: "scons -u test"
118 // End: