4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief DTCPPacket unit tests */
31 //#include "DTCPPacket.test.hh"
32 //#include "DTCPPacket.test.ih"
35 #include "DTCPPacket.hh"
36 #include <senf/Utils/String.hh>
38 #include <senf/Utils/auto_unit_test.hh>
39 #include <boost/test/test_tools.hpp>
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 SENF_AUTO_UNIT_TEST(dtcpPacket)
46 unsigned char data[] = {
47 0x11, // versionNumber = 1, command = JOIN
49 0x0A, 0x0B, // sequence number
50 0x14, // receiveCapable = true, ipVersion = 4
54 101, 102, 103, 104, // fbip1
55 201, 202, 203, 204 // fbip2
58 senf::DTCPHelloPacket hello (senf::DTCPHelloPacket::create(
59 boost::make_iterator_range(data, data+sizeof(data))));
61 BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
62 hello.data().begin(), hello.data().end() );
64 BOOST_CHECK_EQUAL( senf::bytes(hello.parser()), 16u );
66 BOOST_CHECK_EQUAL( hello->versionNumber(), 1u );
67 BOOST_CHECK_EQUAL( hello->command(), unsigned(senf::DTCPHelloPacket::Parser::JOIN) );
68 BOOST_CHECK_EQUAL( hello->interval(), 5u );
69 BOOST_CHECK_EQUAL( hello->sequenceNumber(), 0x0A0Bu );
70 BOOST_CHECK_EQUAL( hello->receiveCapableFeed(), true );
71 BOOST_CHECK_EQUAL( hello->ipVersion(), 4u );
72 BOOST_CHECK_EQUAL( hello->tunnelProtocol(), 23u );
73 BOOST_CHECK_EQUAL( hello->fbipCount(), 2u );
74 BOOST_CHECK( hello->has_v4fbipList() );
75 BOOST_CHECK_EQUAL( senf::str(hello->v4fbipList()[0]), "101.102.103.104" );
76 BOOST_CHECK_EQUAL( senf::str(hello->v4fbipList()[1]), "201.202.203.204" );
80 BOOST_CHECK_EQUAL( ss.str(),
81 "DTCP HELLO Packet:\n"
85 " sequence number : 2571\n"
86 " receive capable feed : yes\n"
88 " tunnel protocol : 23\n"
89 " number of BDL ips : 2\n"
92 " 201.202.203.204\n" );
94 senf::DTCPHelloPacket hello2 (senf::DTCPHelloPacket::create());
96 SENF_CHECK_NO_THROW( hello2->versionNumber() = 1u );
97 SENF_CHECK_NO_THROW( hello2->command() = senf::DTCPHelloPacket::Parser::JOIN );
98 SENF_CHECK_NO_THROW( hello2->interval() = 5u );
99 SENF_CHECK_NO_THROW( hello2->sequenceNumber() = 0x0A0B );
100 SENF_CHECK_NO_THROW( hello2->receiveCapableFeed() = true );
101 SENF_CHECK_NO_THROW( hello2->tunnelProtocol() = 23u );
102 SENF_CHECK_NO_THROW( hello2->init_v4fbipList() );
103 SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0x65666768u) ) );
104 SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0xC9CACBCCu) ) );
106 BOOST_CHECK_EQUAL( senf::bytes(hello2.parser()), 16u );
107 BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
108 hello2.data().begin(), hello2.data().end() );
111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
118 // comment-column: 40
119 // c-file-style: "senf"
120 // indent-tabs-mode: nil
121 // ispell-local-dictionary: "american"
122 // compile-command: "scons -u test"