torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/InstancePinUnitTest.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 InstancePin class.
18 
19 #include <boost/test/unit_test.hpp>
22 
23 namespace torc {
24 namespace physical {
25 
26 BOOST_AUTO_TEST_SUITE(physical)
27 
28 /// \brief Unit test for the InstancePin class.
29 BOOST_AUTO_TEST_CASE(InstancePinUnitTest) {
30  // create an accessory instance
31  InstanceSharedPtr instance1Ptr = Factory::newInstancePtr("name1", "type", "tile", "site");
32  InstanceSharedPtr instance2Ptr = Factory::newInstancePtr("name2", "type", "tile", "site");
33 
34  // functions tested:
35  // InstancePin(InstanceSharedPtr inInstancePtr, const string& inPinName);
36  // create an instance pin and verify that we can recover what we put into it
37  std::string pinName = "pin";
38  InstancePinSharedPtr instancePin1Ptr = Factory::newInstancePinPtr(instance1Ptr, "");
39  InstancePinSharedPtr instancePin2Ptr = Factory::newInstancePinPtr(instance2Ptr, pinName);
40 
41  // functions tested:
42  // const InstanceWeakPtr& getInstancePtr(void) const;
43  // const PinName& getPinName(void) const;
44  // void setInstancePtr(const InstanceWeakPtr& inInstancePtr);
45  // void setPinName(const string& inPinName);
46  BOOST_CHECK(*(instancePin1Ptr->getInstancePtr().lock()) == *instance1Ptr);
47  BOOST_CHECK(instancePin1Ptr->getPinName().empty());
48  instancePin1Ptr->setInstancePtr(instance2Ptr);
49  instancePin1Ptr->setPinName(pinName);
50  BOOST_CHECK(*(instancePin1Ptr->getInstancePtr().lock()) == *instance2Ptr);
51  BOOST_CHECK(instancePin1Ptr->getPinName() == pinName);
52 
53  // functions tested:
54  // bool operator ==(const InstancePin& rhs) const;
55  BOOST_CHECK(*instancePin1Ptr == *instancePin2Ptr);
56 }
57 
58 BOOST_AUTO_TEST_SUITE_END()
59 
60 } // namespace physical
61 } // namespace torc
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
std::string string
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
static InstanceSharedPtr newInstancePtr(const string &inName, const string &inType, const string &inTile, const string &inSite, EInstanceBonding inBonding=eInstanceBondingUnknown, InstanceReferenceSharedPtr inInstanceReferencePtr=InstanceReferenceSharedPtr())
Construct and return a new Instance shared pointer.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
static InstancePinSharedPtr newInstancePinPtr(InstanceSharedPtr inInstancePtr, const string &inPinName)
Construct and return a new InstancePin shared pointer.
Header for the Factory class.
Header for the InstancePin class.