torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PackageUnitTest.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 Package class.
18 
19 #include <boost/test/unit_test.hpp>
22 
23 namespace torc {
24 namespace architecture {
25 
26 BOOST_AUTO_TEST_SUITE(architecture)
27 
28 /// \brief Unit test for the Package class.
29 BOOST_AUTO_TEST_CASE(PackageUnitTest) {
30  // members tested:
31  // string mName;
32  // PadArray mPads;
33  // PadNameToPadIndexMap mPadNameToPadIndex;
34  // functions tested:
35  // Package(const string& inName);
36  // PadArray& getPads(void);
37  // const string& getName(void) const;
38  // const PadArray& getPads(void) const;
39  // PadIndex findPadIndexByName(const string& inName) const;
40  int index = 0;
41  std::string name1("pad1");
42  std::string name2("pad2");
43  std::string name3("pad3");
44  Pad pad1(xilinx::SiteIndex(), name1, xilinx::SiteFlags());
45  Pad pad2(xilinx::SiteIndex(), name2, xilinx::SiteFlags());
46  Pad pad3(xilinx::SiteIndex(), name3, xilinx::SiteFlags());
47  std::string name("name");
48  Package package1(name);
49  PadArray& pads1 = package1.getPads();
50  pads1.setSize(3);
51  package1.mPadNameToPadIndex[name1] = xilinx::PadIndex(index);
52  const_cast<Pad&>(pads1[index++]) = pad1;
53  package1.mPadNameToPadIndex[name2] = xilinx::PadIndex(index);
54  const_cast<Pad&>(pads1[index++]) = pad2;
55  package1.mPadNameToPadIndex[name3] = xilinx::PadIndex(index);
56  const_cast<Pad&>(pads1[index++]) = pad3;
57  BOOST_CHECK_EQUAL(package1.getName(), name);
58  const PadArray& pads2 = package1.getPads();
59  index = 0;
60  BOOST_CHECK_EQUAL(pads2[index++].getName(), pad1.getName());
61  BOOST_CHECK_EQUAL(pads2[index++].getName(), pad2.getName());
62  BOOST_CHECK_EQUAL(pads2[index++].getName(), pad3.getName());
63  BOOST_CHECK_EQUAL(package1.findPadIndexByName(name1), xilinx::PadIndex(0));
64  BOOST_CHECK_EQUAL(package1.findPadIndexByName(name2), xilinx::PadIndex(1));
65  BOOST_CHECK_EQUAL(package1.findPadIndexByName(name3), xilinx::PadIndex(2));
66 
67  // functions tested:
68  // Package(void);
69  // PadArray& getPads(void);
70  Package package2;
71  BOOST_CHECK_EQUAL(package2.getName(), "");
72  BOOST_CHECK_EQUAL(package2.getPads().getSize(), 0u);
73 }
74 
75 BOOST_AUTO_TEST_SUITE_END()
76 
77 } // namespace architecture
78 } // namespace torc
const string & getName(void) const
Returns the name of the pad in its physical package.
Definition: Pad.hpp:64
Encapsulation of the site index, pin name, and pin flags for a package.
Definition: Pad.hpp:33
Encapsulation of a physical device package and its pins.
Definition: Package.hpp:33
PadNameToPadIndexMap mPadNameToPadIndex
The map from pad names to corresponding map indexes.
Definition: Package.hpp:51
BOOST_AUTO_TEST_CASE(ArcUnitTest)
Unit test for the Arc class.
Definition: ArcUnitTest.cpp:29
const string & getName(void) const
Returns the package name.
Definition: Package.hpp:64
std::string string
Encapsulation of site attribute flags in an unsigned 16-bit integer.
PadIndex findPadIndexByName(const string &inName) const
Returns the pad index corresponding to the given pad name.
Definition: Package.hpp:69
Encapsulation of a site index in an unsigned 32-bit integer.
PadArray & getPads(void)
Returns a non-constant array of package pads.
Definition: Package.hpp:57
Header for the DDB class.
void setSize(uint32_t inSize)
Discards all contents and resizes the array.
Definition: Array.hpp:107
Header for the Package class.
Encapsulation of a pad index in an unsigned 32-bit integer.