4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief DTCPPacket.test unit tests */
26 //#include "DTCPPacket.test.hh"
27 //#include "DTCPPacket.test.ih"
30 #include "DTCPPacket.hh"
32 #include "../../Utils/auto_unit_test.hh"
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
38 BOOST_AUTO_UNIT_TEST(dtcpPacket)
40 unsigned char data[] = { 0x11, // versionNumber = 1, command = JOIN
42 0x0A, 0x0B, // sequence number
43 0x14, // receiveCapable = true, ipVersion = 4
47 101, 102, 103, 104, // fbip1
48 201, 202, 203, 204 }; // fbip2
50 senf::DTCPHelloPacket hello (senf::DTCPHelloPacket::create(
51 boost::make_iterator_range(data, data+sizeof(data))));
53 BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
54 hello.data().begin(), hello.data().end() );
56 BOOST_CHECK_EQUAL( senf::bytes(hello.parser()), 16u );
58 BOOST_CHECK_EQUAL( hello->versionNumber(), 1u );
59 BOOST_CHECK_EQUAL( hello->command(), unsigned(senf::DTCPHelloPacket::Parser::JOIN) );
60 BOOST_CHECK_EQUAL( hello->interval(), 5u );
61 BOOST_CHECK_EQUAL( hello->sequenceNumber(), 0x0A0Bu );
62 BOOST_CHECK_EQUAL( hello->receiveCapableFeed(), true );
63 BOOST_CHECK_EQUAL( hello->ipVersion(), 4u );
64 BOOST_CHECK_EQUAL( hello->tunnelProtocol(), 23u );
65 BOOST_CHECK_EQUAL( hello->fbipCount(), 2u );
66 BOOST_CHECK( hello->has_v4fbipList() );
67 BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(hello->v4fbipList()[0]), "101.102.103.104" );
68 BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(hello->v4fbipList()[1]), "201.202.203.204" );
72 BOOST_CHECK_EQUAL( ss.str(),
73 "DTCP HELLO Packet:\n"
77 " sequence number : 2571\n"
78 " receive capable feed : yes\n"
80 " tunnel protocol : 23\n"
81 " number of BDL ips : 2\n"
84 " 201.202.203.204\n" );
86 senf::DTCPHelloPacket hello2 (senf::DTCPHelloPacket::create());
88 SENF_CHECK_NO_THROW( hello2->versionNumber() = 1u );
89 SENF_CHECK_NO_THROW( hello2->command() = senf::DTCPHelloPacket::Parser::JOIN );
90 SENF_CHECK_NO_THROW( hello2->interval() = 5u );
91 SENF_CHECK_NO_THROW( hello2->sequenceNumber() = 0x0A0B );
92 SENF_CHECK_NO_THROW( hello2->receiveCapableFeed() = true );
93 SENF_CHECK_NO_THROW( hello2->tunnelProtocol() = 23u );
94 SENF_CHECK_NO_THROW( hello2->init_v4fbipList() );
95 SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0x65666768u) ) );
96 SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0xC9CACBCCu) ) );
98 BOOST_CHECK_EQUAL( senf::bytes(hello2.parser()), 16u );
99 BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
100 hello2.data().begin(), hello2.data().end() );
103 ///////////////////////////////cc.e////////////////////////////////////////
110 // comment-column: 40
111 // c-file-style: "senf"
112 // indent-tabs-mode: nil
113 // ispell-local-dictionary: "american"
114 // compile-command: "scons -u test"