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/XdlExporterUnitTest.cpp $ 00003 // $Id: XdlExporterUnitTest.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 XdlExporter class. 00018 /// \see DesignRegressionTest.cpp and SampleCodeUnitTest.cpp. 00019 00020 /// \file 00021 /// \brief Unit test for the XdlExporter class. 00022 00023 #include <boost/test/unit_test.hpp> 00024 #include "torc/physical/XdlExporter.hpp" 00025 #include "torc/physical/XdlImporter.hpp" 00026 #include "torc/common/DirectoryTree.hpp" 00027 #include "torc/common/TestHelpers.hpp" 00028 #include <fstream> 00029 00030 namespace torc { 00031 namespace physical { 00032 00033 BOOST_AUTO_TEST_SUITE(physical) 00034 00035 /// \brief Unit test for the XdlExporter class. 00036 BOOST_AUTO_TEST_CASE(XdlExporterUnitTest) { 00037 // create the appropriate file paths 00038 boost::filesystem::path generatedPath = torc::common::DirectoryTree::getExecutablePath() 00039 / "regression" / "XdlExporterUnitTest.generated.xdl"; 00040 boost::filesystem::path referencePath = torc::common::DirectoryTree::getExecutablePath() 00041 / "torc" / "physical" / "ModuleTransformerUnitTest.Scenario.02.Flatten.xdl"; 00042 00043 // import the XDL design 00044 std::fstream fileStream(referencePath.string().c_str()); 00045 BOOST_REQUIRE(fileStream.good()); 00046 XdlImporter importer; 00047 importer(fileStream, referencePath.string()); 00048 00049 // look up the design 00050 DesignSharedPtr designPtr = importer.getDesignPtr(); 00051 BOOST_REQUIRE(designPtr.get() != 0); 00052 00053 // members tested: 00054 // std::ostream& mStream; 00055 // int mIndentCount; 00056 // std::string mIndentString; 00057 // functions tested: 00058 // XdlExporter(std::ostream& inStream, const std::string& inIndentString = "\t"); 00059 // void operator() (const DesignSharedPtr& inDesignPtr); 00060 // void indent(void) const; 00061 // void write(const Circuit& circuit); 00062 // void write(const Design& design); 00063 // void write(const Module& module); 00064 // void write(const Port& port); 00065 // void write(const Instance& instance); 00066 // void write(const Net& net); 00067 // void write(const InstancePin& instancePin, EPinDirection pinDirection, bool comma); 00068 // void write(const Pip& pip, bool comma); 00069 // void write(const Routethrough& routethrough); 00070 // void write(const ConfigMap& configMap); 00071 // export the XDL design 00072 std::fstream xdlExport(generatedPath.string().c_str(), std::ios_base::out); 00073 XdlExporter fileExporter(xdlExport); 00074 fileExporter(designPtr); 00075 BOOST_CHECK(torc::common::fileContentsAreEqual(generatedPath, referencePath)); 00076 } 00077 00078 BOOST_AUTO_TEST_SUITE_END() 00079 00080 } // namespace physical 00081 } // namespace torc