torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrameSetUnitTest.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Unit test for the FrameSet class.
18 
21 #include <boost/test/unit_test.hpp>
22 
23 namespace torc {
24 namespace bitstream {
25 
26 BOOST_AUTO_TEST_SUITE(bitstream)
27 
28 /// \brief Unit test for the FrameSet class.
29 BOOST_AUTO_TEST_CASE(FrameSetUnitTest) {
30  // functions tested:
31  // FrameSet(uint32_t inFrameLength, uint32_t inFrameCount);
32  const boost::uint32_t length = 0x41;
33  const boost::uint32_t count = 5;
34  VirtexFrameSet virtexFrameSet(length, count);
35  BOOST_CHECK_EQUAL(virtexFrameSet.size(), count);
36  VirtexFrameSet::const_iterator p = virtexFrameSet.begin();
37  VirtexFrameSet::const_iterator e = virtexFrameSet.end();
38  while(p < e) {
39  const VirtexFrameSharedPtr& vfsp = *p++;
40  BOOST_CHECK_EQUAL(vfsp->getLength(), length);
41 // const VirtexFrame& vf = **p++;
42 // BOOST_CHECK_EQUAL(vf.getLength(), length);
43  }
44 }
45 
46 /// \brief Unit test for the FrameBlocks class.
47 BOOST_AUTO_TEST_CASE(FrameBlocksUnitTest) {
48  // members tested:
49  // mBlock[];
50  const boost::uint32_t length = 0x41;
51  VirtexFrameBlocks blocks;
52  int count[Bitstream::eBlockTypeCount] = { 1000, 1000, 500 };
53  for(int i = 0; i < Bitstream::eBlockTypeCount; i++) {
54  for(int j = 0; j < count[i]; j++) {
55  blocks.mBlock[i].push_back(
57  }
58  }
59  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType0].size(), 1000u);
60  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType1].size(), 1000u);
61  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType2].size(), 500u);
62  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType3].size(), 0u);
63  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType4].size(), 0u);
64  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType5].size(), 0u);
65  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType6].size(), 0u);
66  BOOST_CHECK_EQUAL(blocks.mBlock[Virtex5::eFarBlockType7].size(), 0u);
67 }
68 
69 BOOST_AUTO_TEST_SUITE_END()
70 
71 } // namespace bitstream
72 } // namespace torc
Frame< uint32_t > VirtexFrame
Virtex frame type.
Definition: Frame.hpp:104
Header for the Virtex5 class.
Header for the FrameSet class.
FrameSet< FRAME_TYPE > mBlock[Bitstream::eBlockTypeCount]
FrameSets for each of the eight block types.
Definition: FrameSet.hpp:88
boost::shared_ptr< VirtexFrame > FrameSharedPtr
Shared pointer encapsulation of a Frame.
Definition: FrameSet.hpp:44
boost::shared_ptr< VirtexFrame > VirtexFrameSharedPtr
Virtex frame type.
Definition: Frame.hpp:108
BOOST_AUTO_TEST_CASE(hexCharacterToDec)