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/PortUnitTest.cpp $ 00003 // $Id: PortUnitTest.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 Port class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/Factory.hpp" 00021 #include "torc/physical/Pip.hpp" 00022 00023 namespace torc { 00024 namespace physical { 00025 00026 BOOST_AUTO_TEST_SUITE(physical) 00027 00028 /// \brief Unit test for the Port class. 00029 BOOST_AUTO_TEST_CASE(PortUnitTest) { 00030 // create an accessory instance 00031 InstanceSharedPtr instancePtr = Factory::newInstancePtr("name", "type", "tile", "site", 00032 eInstanceBondingUnknown); 00033 BOOST_REQUIRE(instancePtr.get() != 0); 00034 00035 // functions tested: 00036 // Port(const string& inName, InstanceSharedPtr inInstancePtr, const string& inPinName); 00037 std::string name = "name"; 00038 std::string pin = "pin"; 00039 PortSharedPtr port1Ptr = Factory::newPortPtr(name, instancePtr, pin); 00040 PortSharedPtr port2Ptr = Factory::newPortPtr(name, instancePtr, pin); 00041 BOOST_REQUIRE(port1Ptr.get() != 0); 00042 BOOST_REQUIRE(port2Ptr.get() != 0); 00043 00044 // functions tested: 00045 // const InstanceWeakPtr& getInstancePtr(void) const; 00046 // const PinName& getPinName(void) const; 00047 BOOST_CHECK(port1Ptr->getInstancePtr().lock() == instancePtr); 00048 BOOST_CHECK(port1Ptr->getPinName() == pin); 00049 00050 // functions tested: 00051 // bool operator ==(const Port& rhs) const; 00052 BOOST_CHECK(*port1Ptr == *port2Ptr); // name based comparison 00053 } 00054 00055 BOOST_AUTO_TEST_SUITE_END() 00056 00057 } // namespace physical 00058 } // namespace torc