houston, we have a problem...
[senf.git] / Packets / MPEGDVBBundle / TLVPacket.test.cc
1 // $Id: TransportPacket.test.cc 389 2007-08-10 15:06:54Z tho $
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.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 // Unit tests
24
25 //#include "TLVPacket.test.hh"
26 //#include "TLVPacket.test.ih"
27
28 // Custom includes
29 #include "TLVPacket.hh"
30 #include <senf/Packets.hh>
31 #include <senf/Utils/hexdump.hh>
32
33 #include <boost/test/auto_unit_test.hpp>
34 #include <boost/test/test_tools.hpp>
35
36 #define prefix_
37 ///////////////////////////////cc.p////////////////////////////////////////
38
39 using namespace senf;
40
41 BOOST_AUTO_UNIT_TEST(tlvPacket_parse_packet_with_extended_length)
42 {
43     unsigned char data[] = { 
44         0x01, 0x23, 0x45, 0x67, // type
45         0x81, // first and last bit set => one byte length following
46         0x0A, // length (10 bytes value)
47         0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A  // value (payload)
48     };
49             
50     senf::TLVPacket p (senf::TLVPacket::create(data));
51     
52 #include <iostream>
53     p.dump(std::cout);
54
55     BOOST_CHECK_EQUAL( p->type(), 0x01234567u );
56     BOOST_CHECK_EQUAL( p->length(), 0x0Au );
57
58     senf::PacketData & p_value (p.next().data());
59     senf::hexdump( p_value.begin(), p_value.end(), std::cout );
60     
61 //    BOOST_CHECK_EQUAL( p_value.size(), 0x0Au);
62 }
63
64 ///////////////////////////////cc.e////////////////////////////////////////
65 #undef prefix_
66
67 \f
68 // Local Variables:
69 // mode: c++
70 // fill-column: 100
71 // c-file-style: "senf"
72 // indent-tabs-mode: nil
73 // ispell-local-dictionary: "american"
74 // compile-command: "scons -u test"
75 // comment-column: 40
76 // End: