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/InstanceReferenceUnitTest.cpp $ 00003 // $Id: InstanceReferenceUnitTest.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 InstanceReference 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 InstanceReference class. 00029 BOOST_AUTO_TEST_CASE(InstanceReferenceUnitTest) { 00030 // create the accessory instance and module 00031 ModuleSharedPtr modulePtr = Factory::newModulePtr("name", "anchor"); 00032 InstanceSharedPtr instancePtr = Factory::newInstancePtr("name", "type", "tile", "site"); 00033 00034 // functions tested: 00035 // InstanceReference(const string& inInstantiationName, ModuleSharedPtr inModulePtr, 00036 // InstanceSharedPtr inInstancePtr); 00037 // create an instance reference and verify that we can recover what we put into it 00038 std::string name = "name"; 00039 InstanceReferenceSharedPtr instanceReference1Ptr = Factory::newInstanceReferencePtr(name, 00040 modulePtr, instancePtr); 00041 InstanceReferenceSharedPtr instanceReference2Ptr = Factory::newInstanceReferencePtr(name, 00042 modulePtr, instancePtr); 00043 BOOST_REQUIRE(instanceReference1Ptr != 0); 00044 BOOST_REQUIRE(instanceReference2Ptr != 0); 00045 00046 // functions tested: 00047 // const ModuleWeakPtr& getModulePtr(void) const; 00048 // const InstanceWeakPtr& getInstancePtr(void) const; 00049 // const string& getInstantiationName(void) const; 00050 BOOST_CHECK(*(instanceReference1Ptr->getInstancePtr().lock()) == *instancePtr); 00051 BOOST_CHECK(*(instanceReference1Ptr->getModulePtr().lock()) == *modulePtr); 00052 BOOST_CHECK(instanceReference1Ptr->getInstantiationName() == name); 00053 00054 // functions tested: 00055 // bool operator ==(const InstanceReference& rhs) const; 00056 BOOST_CHECK(*instanceReference1Ptr == *instanceReference2Ptr); 00057 } 00058 00059 BOOST_AUTO_TEST_SUITE_END() 00060 00061 } // namespace physical 00062 } // namespace torc