2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief ParseListN.test unit tests */
24 //#include "ParseListN.test.hh"
25 //#include "ParseListN.test.ih"
30 #include <boost/test/auto_unit_test.hpp>
31 #include <boost/test/test_tools.hpp>
34 ///////////////////////////////cc.p////////////////////////////////////////
37 struct VoidPacket_Type : public senf::PacketTypeBase
39 typedef senf::ConcretePacket<VoidPacket_Type> VoidPacket;
42 BOOST_AUTO_UNIT_TEST(parseListN)
44 typedef senf::Parse_VectorN<senf::Parse_UInt16,senf::Parse_UInt8>::parser ParseVec;
45 typedef senf::Parse_ListN<ParseVec,senf::Parse_UInt16>::parser ParseList;
47 VoidPacket vp (VoidPacket::create(ParseList::init_bytes));
50 ParseList p (vp.data().begin(),&vp.data());
52 BOOST_CHECK_EQUAL( p.size(), 0u );
53 BOOST_CHECK_EQUAL( p.bytes(), 2u );
54 BOOST_CHECK( p.empty() );
55 BOOST_CHECK( p.begin() == p.end() );
59 # define p ParseList(vp.data().begin(),&vp.data())
62 BOOST_CHECK_EQUAL( p.bytes(), 3u );
63 BOOST_CHECK_EQUAL( p.size(), 1u );
64 BOOST_CHECK_EQUAL( p.front().bytes(), 1u );
65 BOOST_CHECK_EQUAL( p.front().size(), 0u );
66 BOOST_CHECK_EQUAL( vp.data()[1], 0x01u );
68 p.front().push_back(0x1234u);
69 BOOST_CHECK_EQUAL( p.front().size(), 1u );
70 BOOST_CHECK_EQUAL( p.front().bytes(), 3u );
71 BOOST_CHECK_EQUAL( p.front()[0], 0x1234u );
72 BOOST_CHECK_EQUAL( p.size(), 1u );
73 BOOST_CHECK_EQUAL( p.bytes(), 5u );
75 p.front().push_back(0x2345u);
76 BOOST_CHECK_EQUAL( p.front().back(), 0x2345u );
77 BOOST_CHECK_EQUAL( p.bytes(), 7u );
80 BOOST_CHECK_EQUAL( p.size(), 2u );
81 BOOST_CHECK_EQUAL( p.bytes(), 8u );
83 p.back().push_front(0x0123u);
84 BOOST_CHECK_EQUAL( p.front().size(), 2u );
85 BOOST_CHECK_EQUAL( p.back().size(), 1u );
87 p.push_front_space(2u);
88 BOOST_CHECK_EQUAL( p.size(), 4u );
89 BOOST_CHECK_EQUAL( p.front().size(), 0u);
92 BOOST_CHECK_EQUAL( p.size(), 3u );
93 BOOST_CHECK_EQUAL( p.back()[0], 0x1234u );
94 BOOST_CHECK_EQUAL( p.bytes(), 9u );
100 BOOST_AUTO_UNIT_TEST(parseListN_container)
102 typedef senf::Parse_VectorN<senf::Parse_UInt16,senf::Parse_UInt8>::parser ParseVec;
103 typedef senf::Parse_ListN<ParseVec,senf::Parse_UInt16>::parser ParseList;
105 VoidPacket vp (VoidPacket::create(ParseList::init_bytes));
107 ParseList(vp.data().begin(),&vp.data()).init();
113 ///////////////////////////////cc.e////////////////////////////////////////
120 // comment-column: 40
121 // c-file-style: "senf"
122 // indent-tabs-mode: nil
123 // ispell-local-dictionary: "american"
124 // compile-command: "scons -u test"