4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@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 psi2ts unit tests */
27 #include "senf/PPI/DebugModules.hh"
28 #include "senf/PPI/Setup.hh"
29 #include <senf/Packets/MPEGDVBBundle/MPESection.hh>
30 #include <senf/Packets/MPEGDVBBundle/TransportPacket.hh>
33 #include "../../Utils/auto_unit_test.hh"
34 #include <boost/test/test_tools.hpp>
35 #include <boost/lambda/lambda.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
40 void check_transportpacket_header(senf::TransportPacket tsPacket, bool pusi, unsigned pid, unsigned counter)
42 BOOST_CHECK_EQUAL( tsPacket->sync_byte(), senf::TransportPacketType::SYNC_BYTE+0 );
43 BOOST_CHECK_EQUAL( tsPacket->transport_error_indicator(), false );
44 BOOST_CHECK_EQUAL( tsPacket->pusi(), pusi );
45 BOOST_CHECK_EQUAL( tsPacket->transport_priority(), false );
46 BOOST_CHECK_EQUAL( tsPacket->transport_scrmbl_ctrl(), 0x0u );
47 BOOST_CHECK_EQUAL( tsPacket->adaptation_field_ctrl(), 0x1u );
48 BOOST_CHECK_EQUAL( tsPacket->continuity_counter(), counter );
52 BOOST_AUTO_UNIT_TEST(one_section_to_one_transportpacket)
54 senf::ppi::module::debug::ActiveSource source;
55 senf::ppi::module::debug::PassiveSink sink;
58 senf::ppi::connect(source, psi2ts);
59 senf::ppi::connect(psi2ts, sink);
62 std::string payload_data ( "psi2ts_test: one_section_to_one_transportpacket");
63 senf::Packet payload (senf::DataPacket::create(payload_data));
66 source.submit(payload);
67 BOOST_CHECK_EQUAL( sink.size(), 1u);
69 senf::TransportPacket tsPacket = sink.pop_front().as<senf::TransportPacket>();
70 check_transportpacket_header( tsPacket, true, 0, 1);
71 senf::PacketData & ts_data = tsPacket.next().data();
72 BOOST_CHECK_EQUAL_COLLECTIONS(
74 boost::next( ts_data.begin(), payload_data.size()),
77 // BOOST_CHECK( std::find_if(
78 // boost::next( ts_data.begin(), payload_data.size()),
80 // boost::lambda::_1 != 0xffu) == ts_data.end() );
84 ///////////////////////////////cc.e////////////////////////////////////////
92 // c-file-style: "senf"
93 // indent-tabs-mode: nil
94 // ispell-local-dictionary: "american"
95 // compile-command: "scons -u test"