torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ArcUnitTest.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 Arc class.
18 
19 #include <boost/test/unit_test.hpp>
21 #include <iostream>
22 
23 namespace torc {
24 namespace architecture {
25 
26 BOOST_AUTO_TEST_SUITE(architecture)
27 
28 /// \brief Unit test for the Arc class.
29 BOOST_AUTO_TEST_CASE(ArcUnitTest) {
30  // supporting variables
33 
34  // members tested:
35  // Tilewire mSourceTilewire;
36  // Tilewire mSinkTilewire;
37  // functions tested:
38  // Arc(void);
39  // Arc(const Tilewire& inSourceTilewire, const Tilewire& inSinkTilewire);
40  // bool operator ==(const Arc& rhs) const;
41  // bool operator <(const Arc& rhs) const;
42  // bool isUndefined(void) const;
43  Arc arc1;
44  Arc arc2;
45  Arc arc3(tilewire1, tilewire2);
46  Arc arc4(tilewire2, tilewire1);
47  BOOST_CHECK((arc1 == arc2) == true);
48  BOOST_CHECK((arc1 == arc3) == false);
49  BOOST_CHECK((arc3 < arc4) == true);
50  BOOST_CHECK((arc4 < arc3) == false);
51  BOOST_CHECK(arc1.isUndefined());
52 
53  // functions tested:
54  // const Tilewire& getSourceTilewire(void) const;
55  // const Tilewire& getSinkTilewire(void) const;
56  BOOST_CHECK(arc3.getSourceTilewire() == tilewire1);
57  BOOST_CHECK(arc3.getSinkTilewire() == tilewire2);
58 
59  // functions tested:
60  // friend std::size_t hash_value(const Arc& inArc);
61  BOOST_CHECK_EQUAL(hash_value(arc1), hash_value(arc2));
62 }
63 
64 BOOST_AUTO_TEST_SUITE_END()
65 
66 } // namespace architecture
67 } // namespace torc
Encapsulation of a tile index in an unsigned 32-bit integer.
Encapsulation of an arc between two tilewires.
Definition: Arc.hpp:28
BOOST_AUTO_TEST_CASE(ArcUnitTest)
Unit test for the Arc class.
Definition: ArcUnitTest.cpp:29
Header for the Arc class.
Encapsulation of a wire index in an unsigned 16-bit integer.
const Tilewire & getSourceTilewire(void) const
Returns the source tilewire.
Definition: Arc.hpp:45
const Tilewire & getSinkTilewire(void) const
Returns the sink tilewire.
Definition: Arc.hpp:47
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
bool isUndefined(void) const
Definition: Arc.hpp:61
std::size_t hash_value(const Arc &inArc)
Definition: Arc.cpp:25