00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/physical/InstancePinUnitTest.cpp $ 00003 // $Id: InstancePinUnitTest.cpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Unit test for the InstancePin class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/Factory.hpp" 00021 #include "torc/physical/InstancePin.hpp" 00022 00023 namespace torc { 00024 namespace physical { 00025 00026 BOOST_AUTO_TEST_SUITE(physical) 00027 00028 /// \brief Unit test for the InstancePin class. 00029 BOOST_AUTO_TEST_CASE(InstancePinUnitTest) { 00030 // create an accessory instance 00031 InstanceSharedPtr instance1Ptr = Factory::newInstancePtr("name1", "type", "tile", "site"); 00032 InstanceSharedPtr instance2Ptr = Factory::newInstancePtr("name2", "type", "tile", "site"); 00033 00034 // functions tested: 00035 // InstancePin(InstanceSharedPtr inInstancePtr, const string& inPinName); 00036 // create an instance pin and verify that we can recover what we put into it 00037 std::string pinName = "pin"; 00038 InstancePinSharedPtr instancePin1Ptr = Factory::newInstancePinPtr(instance1Ptr, ""); 00039 InstancePinSharedPtr instancePin2Ptr = Factory::newInstancePinPtr(instance2Ptr, pinName); 00040 00041 // functions tested: 00042 // const InstanceWeakPtr& getInstancePtr(void) const; 00043 // const PinName& getPinName(void) const; 00044 // void setInstancePtr(const InstanceWeakPtr& inInstancePtr); 00045 // void setPinName(const string& inPinName); 00046 BOOST_CHECK(*(instancePin1Ptr->getInstancePtr().lock()) == *instance1Ptr); 00047 BOOST_CHECK(instancePin1Ptr->getPinName().empty()); 00048 instancePin1Ptr->setInstancePtr(instance2Ptr); 00049 instancePin1Ptr->setPinName(pinName); 00050 BOOST_CHECK(*(instancePin1Ptr->getInstancePtr().lock()) == *instance2Ptr); 00051 BOOST_CHECK(instancePin1Ptr->getPinName() == pinName); 00052 00053 // functions tested: 00054 // bool operator ==(const InstancePin& rhs) const; 00055 BOOST_CHECK(*instancePin1Ptr == *instancePin2Ptr); 00056 } 00057 00058 BOOST_AUTO_TEST_SUITE_END() 00059 00060 } // namespace physical 00061 } // namespace torc