4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Christian Niephaus <cni@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 MPLSPacket unit tests */
26 //#include "MPLSPacket.test.hh"
27 //#include "MPLSPacket.test.ih"
30 #include "MPLSPacket.hh"
33 #include "../../Utils/auto_unit_test.hh"
34 #include <boost/test/test_tools.hpp>
37 ///////////////////////////////cc.p////////////////////////////////////////
39 BOOST_AUTO_UNIT_TEST(mplsPacket_parse)
41 senf::PacketData::byte data[] = {
42 0x00, 0x3e, 0x90, 0x80, //1st mpls header
43 0x00, 0x3e, 0xb1, 0x80, // last mpls header
46 senf::MPLSPacket p (senf::MPLSPacket::create(data));
48 BOOST_CHECK_EQUAL( p->label(), 1001u);
49 BOOST_CHECK_EQUAL( p->tc(), 0u );
50 BOOST_CHECK( !p->s());
51 BOOST_CHECK_EQUAL( p->ttl(), 128u );
53 std::ostringstream oss (std::ostringstream::out);
54 SENF_CHECK_NO_THROW( p.dump( oss));
57 BOOST_AUTO_UNIT_TEST(mplsPacket_parse_chain)
59 senf::PacketData::byte data[] = {
60 0x00, 0x3e, 0x90, 0x80, //1st mpls header
61 0x00, 0x3e, 0xb1, 0x80, // last mpls header
65 senf::MPLSPacket p (senf::MPLSPacket::create(data));
67 BOOST_REQUIRE( p.next().is<senf::MPLSPacket>() );
68 senf::MPLSPacket p2 (p.next().as<senf::MPLSPacket>());
69 BOOST_CHECK( p2->s());
70 BOOST_REQUIRE( p2.next().is<senf::DataPacket>() );
73 BOOST_AUTO_UNIT_TEST(mplsPacket_create)
75 senf::MPLSPacket p (senf::MPLSPacket::create());
81 SENF_CHECK_NO_THROW(p.finalizeThis());
86 ///////////////////////////////cc.e////////////////////////////////////////
93 // c-file-style: "senf"
94 // indent-tabs-mode: nil
95 // ispell-local-dictionary: "american"
96 // compile-command: "scons -u test"