torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TilewireUnitTest.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 Tilewire class.
18 
19 #include <boost/test/unit_test.hpp>
22 
23 namespace torc {
24 namespace architecture {
25 namespace xilinx {
26 
27 BOOST_AUTO_TEST_SUITE(architecture)
28 
29 /// \brief Unit test for the Tilewire class.
30 BOOST_AUTO_TEST_CASE(TilewireUnitTest) {
31  // create accessory wires and tiles
32  WireIndex wire1(15);
33  WireIndex wire2(300);
34  TileIndex tile1(1);
35  TileIndex tile2(1);
36 
37  // features tested:
38  // sizeof(Tilewire)
39  BOOST_CHECK_EQUAL(sizeof(Tilewire), (sizeof(TileIndex) + sizeof(WireIndex)));
40  BOOST_CHECK_EQUAL(sizeof(Tilewire), 6u);
41 
42  // functions tested:
43  // Tilewire(void);
44  // Tilewire(const TileIndex& inTileIndex, const WireIndex& inWireIndex);
45  // Tilewire(const Tilewire& inTilewire);
46  // bool operator ==(const Tilewire& rhs) const;
47  Tilewire tilewire1(tile1, wire1);
48  Tilewire tilewire2(tile2, wire2);
49  Tilewire tilewire3(tilewire1);
50  Tilewire tilewire4 = tilewire1;
51  Tilewire tilewire5;
52  BOOST_CHECK_EQUAL(tilewire1 == tilewire2, false);
53  BOOST_CHECK_EQUAL(tilewire1 == tilewire3, true);
54 
55  // functions tested:
56  // const TileIndex& getTileIndex(void) const;
57  // const WireIndex& getWireIndex(void) const;
58  // void setTileIndex(const TileIndex& inTileIndex);
59  // void setWireIndex(const WireIndex& inWireIndex);
60  BOOST_CHECK_EQUAL(tilewire3.getTileIndex(), tile1);
61  BOOST_CHECK_EQUAL(tilewire3.getWireIndex(), wire1);
62  BOOST_CHECK_EQUAL(tilewire5.getTileIndex(), TileIndex::undefined());
63  BOOST_CHECK_EQUAL(tilewire5.getWireIndex(), WireIndex::undefined());
64  tilewire3.setTileIndex(tile2);
65  tilewire3.setWireIndex(wire2);
66  BOOST_CHECK_EQUAL(tilewire3.getTileIndex(), tile2);
67  BOOST_CHECK_EQUAL(tilewire3.getWireIndex(), wire2);
68 
69  // functions tested:
70  // const Tilewire& operator =(const Tilewire& rhs) const;
71  tilewire4 = tilewire2;
72  BOOST_CHECK_EQUAL(tilewire4.getTileIndex(), tile2);
73  BOOST_CHECK_EQUAL(tilewire4.getWireIndex(), wire2);
74 
75  // functions tested:
76  // bool operator <(const Tilewire& rhs) const;
77  BOOST_CHECK_EQUAL(tilewire1 < tilewire2, true);
78  BOOST_CHECK_EQUAL(tilewire2 < tilewire1, false);
79  BOOST_CHECK_EQUAL(tilewire4 < tilewire2, false);
80  BOOST_CHECK_EQUAL(tilewire2 < tilewire4, false);
81 }
82 
83 BOOST_AUTO_TEST_SUITE_END()
84 
85 } // namespace xilinx
86 } // namespace architecture
87 } // namespace torc
const WireIndex & getWireIndex(void) const
Returns the wire index.
Definition: Tilewire.hpp:66
Encapsulation of a tile index in an unsigned 32-bit integer.
Encapsulation of a wire index in an unsigned 16-bit integer.
BOOST_AUTO_TEST_CASE(TilewireUnitTest)
Unit test for the Tilewire class.
Header for torc::physical output stream helpers.
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
Header for the Tilewire class.
void setTileIndex(const TileIndex &inTileIndex)
Sets the tile index.
Definition: Tilewire.hpp:68
const TileIndex & getTileIndex(void) const
Returns the tile index.
Definition: Tilewire.hpp:64
void setWireIndex(const WireIndex &inWireIndex)
Sets the wire index.
Definition: Tilewire.hpp:70