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/FactoryUnitTest.cpp $ 00003 // $Id: FactoryUnitTest.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 Factory class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/Factory.hpp" 00021 00022 namespace torc { 00023 namespace physical { 00024 00025 BOOST_AUTO_TEST_SUITE(physical) 00026 00027 /// \brief Unit test for the Factory class. 00028 BOOST_AUTO_TEST_CASE(FactoryUnitTest) { 00029 // functions tested: 00030 // static DesignSharedPtr newDesignPtr(const string& inName, const string& inDevice, 00031 // const string& inPackage, const string& inSpeedGrade, const string& inXdlVersion); 00032 DesignSharedPtr designPtr = Factory::newDesignPtr("design", "device", "package", "speed", 00033 "version"); 00034 BOOST_REQUIRE(designPtr.get() != 0); 00035 00036 // functions tested: 00037 // static ModuleSharedPtr newModulePtr(const string& inName, const string& inAnchor); 00038 ModuleSharedPtr modulePtr = Factory::newModulePtr("name", "anchor"); 00039 BOOST_REQUIRE(modulePtr.get() != 0); 00040 00041 // functions tested: 00042 // static InstanceSharedPtr newInstancePtr(const string& inName, const string& inType, 00043 // const string& inTile, const string& inSite, EInstanceBonding inBonding, 00044 // InstanceReferenceSharedPtr inInstanceReferencePtr); 00045 InstanceSharedPtr instance1Ptr = Factory::newInstancePtr("name", "type", "tile", "site"); 00046 BOOST_REQUIRE(instance1Ptr.get() != 0); 00047 00048 // functions tested: 00049 // static PortSharedPtr newPortPtr(const string& inName, InstanceSharedPtr inInstancePtr, 00050 // const string& inPinName); 00051 PortSharedPtr portPtr = Factory::newPortPtr("name", instance1Ptr, "pin"); 00052 BOOST_REQUIRE(portPtr.get() != 0); 00053 00054 // functions tested: 00055 // static NetSharedPtr newNetPtr(const string& inName, ENetType inNetType = eNetTypeNormal); 00056 NetSharedPtr net1Ptr = Factory::newNetPtr("name"); 00057 BOOST_REQUIRE(net1Ptr.get() != 0); 00058 00059 // functions tested: 00060 // static InstanceReferenceSharedPtr newInstanceReferencePtr(const string& inInstantiationName, 00061 // ModuleSharedPtr inModulePtr, InstanceSharedPtr inInstancePtr); 00062 InstanceReferenceSharedPtr instanceReferencePtr = Factory::newInstanceReferencePtr("name", 00063 modulePtr, instance1Ptr); 00064 BOOST_REQUIRE(instanceReferencePtr.get() != 0); 00065 00066 // functions tested: 00067 InstanceSharedPtr instance2Ptr = Factory::newInstancePtr("name", "type", "tile", "site", 00068 eInstanceBondingUnknown, instanceReferencePtr); 00069 BOOST_REQUIRE(instance2Ptr.get() != 0); 00070 00071 // functions tested: 00072 // static torc::physical::InstancePin newInstancePinPtr(InstanceSharedPtr inInstancePtr, 00073 // const string& inPinName); 00074 InstancePinSharedPtr instancePinPtr = Factory::newInstancePinPtr(instance2Ptr, "pin"); 00075 BOOST_REQUIRE(instancePinPtr->getInstancePtr().lock() == instance2Ptr); 00076 00077 // functions tested: 00078 // static RoutethroughSharedPtr newRoutethroughPtr(const string& inSetting, 00079 // const string& inName, const string& inValue, const InstanceWeakPtr& inInstancePtr, 00080 // const string& inSourceWireName, const string& inSinkWireName); 00081 RoutethroughSharedPtr routethroughPtr = Factory::newRoutethroughPtr("setting", "name", "value", 00082 instance2Ptr, "source", "sink"); 00083 BOOST_REQUIRE(routethroughPtr.get() != 0); 00084 00085 // functions tested: 00086 // static torc::physical::Pip newPip(const string& inTileName, const string& inSourceWireName, 00087 // const string& inSinkWireName, EPipDirection inPipDirection, 00088 // RoutethroughSharedPtr inRoutethroughPtr); 00089 Pip pip = Factory::newPip("tile", "source", "sink", ePipUnidirectionalBuffered, 00090 routethroughPtr); 00091 BOOST_REQUIRE(pip.getRoutethroughPtr() == routethroughPtr); 00092 } 00093 00094 BOOST_AUTO_TEST_SUITE_END() 00095 00096 } // namespace physical 00097 } // namespace torc