torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeviceDesignatorUnitTest.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 DeviceDesignator class.
18 
19 #include <boost/test/unit_test.hpp>
21 #include <sstream>
22 
23 namespace torc {
24 namespace common {
25 
26 BOOST_AUTO_TEST_SUITE(common)
27 
28 /// \brief Unit test for the DeviceDesignator class.
29 BOOST_AUTO_TEST_CASE(DeviceDesignatorUnitTest) {
30 
31  // functions tested:
32  // DeviceDesignator(const string& inDeviceDesignator);
33  // bool parse(const string& inDeviceDesignator, const boost::regex& inRegEx);
34  DeviceDesignator deviceName0("xc3s1600efg484-5");
35  BOOST_CHECK_EQUAL(deviceName0.getFamily(), DeviceDesignator::eFamilySpartan3E);
36  BOOST_CHECK_EQUAL(deviceName0.getDeviceName(), "xc3s1600e");
37  BOOST_CHECK_EQUAL(deviceName0.getDevicePackage(), "fg484");
38  BOOST_CHECK_EQUAL(deviceName0.getDeviceSpeedGrade(), "-5");
39  DeviceDesignator deviceName1("xcv3200efg1156-8");
40  BOOST_CHECK_EQUAL(deviceName1.getFamily(), DeviceDesignator::eFamilyVirtexE);
41  BOOST_CHECK_EQUAL(deviceName1.getDeviceName(), "xcv3200e");
42  BOOST_CHECK_EQUAL(deviceName1.getDevicePackage(), "fg1156");
43  BOOST_CHECK_EQUAL(deviceName1.getDeviceSpeedGrade(), "-8");
44  DeviceDesignator deviceName2("xc2vp30ff896-7");
45  BOOST_CHECK_EQUAL(deviceName2.getFamily(), DeviceDesignator::eFamilyVirtex2P);
46  BOOST_CHECK_EQUAL(deviceName2.getDeviceName(), "xc2vp30");
47  BOOST_CHECK_EQUAL(deviceName2.getDevicePackage(), "ff896");
48  BOOST_CHECK_EQUAL(deviceName2.getDeviceSpeedGrade(), "-7");
49  DeviceDesignator deviceName3("xc4vfx60ff1152-12");
50  BOOST_CHECK_EQUAL(deviceName3.getFamily(), DeviceDesignator::eFamilyVirtex4);
51  BOOST_CHECK_EQUAL(deviceName3.getDeviceName(), "xc4vfx60");
52  BOOST_CHECK_EQUAL(deviceName3.getDevicePackage(), "ff1152");
53  BOOST_CHECK_EQUAL(deviceName3.getDeviceSpeedGrade(), "-12");
54  DeviceDesignator deviceName4("xc5vfx130tff1738-3");
55  BOOST_CHECK_EQUAL(deviceName4.getFamily(), DeviceDesignator::eFamilyVirtex5);
56  BOOST_CHECK_EQUAL(deviceName4.getDeviceName(), "xc5vfx130t");
57  BOOST_CHECK_EQUAL(deviceName4.getDevicePackage(), "ff1738");
58  BOOST_CHECK_EQUAL(deviceName4.getDeviceSpeedGrade(), "-3");
59  DeviceDesignator deviceName5("xc6vhx380tff1924-3");
60  BOOST_CHECK_EQUAL(deviceName5.getFamily(), DeviceDesignator::eFamilyVirtex6);
61  BOOST_CHECK_EQUAL(deviceName5.getDeviceName(), "xc6vhx380t");
62  BOOST_CHECK_EQUAL(deviceName5.getDevicePackage(), "ff1924");
63  BOOST_CHECK_EQUAL(deviceName5.getDeviceSpeedGrade(), "-3");
64  DeviceDesignator deviceName6("xc7vx485tffg1929-3");
65  BOOST_CHECK_EQUAL(deviceName6.getFamily(), DeviceDesignator::eFamilyVirtex7);
66  BOOST_CHECK_EQUAL(deviceName6.getDeviceName(), "xc7vx485t");
67  BOOST_CHECK_EQUAL(deviceName6.getDevicePackage(), "ffg1929");
68  BOOST_CHECK_EQUAL(deviceName6.getDeviceSpeedGrade(), "-3");
69 
70  // functions tested:
71  // std::ostream& operator<< (std::ostream& os);
72  std::stringstream ss;
73  ss << deviceName6;
74  BOOST_CHECK_EQUAL(ss.str(), "xc7vx485tffg1929-3");
75 
76  // the above tests are not exhaustive
77  //BOOST_CHECK(false);
78 }
79 
80 BOOST_AUTO_TEST_SUITE_END()
81 
82 } // namespace common
83 } // namespace torc
Encapsulation of a device designator and its constituent elements.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DeviceDesignator class.
const string & getDeviceSpeedGrade(void) const
Returns the device speed grade.
BOOST_AUTO_TEST_CASE(AnnotatedUnitTest)
Unit test for the Annotated class.
const string & getDevicePackage(void) const
Returns the device package.
const string & getDeviceName(void) const
Returns the device name.