Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

unitTest.cpp

00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 // Test individual classes or groups of classes
00004 
00005 #if defined(_MSC_VER)
00006 // Turn off compiler warning about long names
00007 #  pragma warning(disable:4786)
00008 #endif
00009 
00010 #include <cassert>
00011 #include <iostream>
00012 
00013 #include "CoinError.hpp"
00014 #include "CoinHelperFunctions.hpp"
00015 #include "CoinSort.hpp"
00016 #include "CoinShallowPackedVector.hpp"
00017 #include "CoinPackedVector.hpp"
00018 #include "CoinDenseVector.hpp"
00019 #include "CoinIndexedVector.hpp"
00020 #include "CoinPackedMatrix.hpp"
00021 #include "CoinMpsIO.hpp"
00022 
00023 // Function Prototypes. Function definitions is in this file.
00024 void testingMessage( const char * const msg );
00025 
00026 //----------------------------------------------------------------
00027 // unitTest [-mpsDir=V1] [-netlibDir=V2]
00028 // 
00029 // where:
00030 //   -mpsDir: directory containing mps test files
00031 //       Default value V1="../Mps/Sample"    
00032 //   -netlibDir: directory containing netlib files
00033 //       Default value V2="../Mps/Netlib"
00034 //
00035 // All parameters are optional.
00036 //----------------------------------------------------------------
00037 
00038 int main (int argc, const char *argv[])
00039 {
00040   int i;
00041 
00042   // define valid parameter keywords
00043   std::set<std::string> definedKeyWords;
00044   definedKeyWords.insert("-mpsDir");
00045   definedKeyWords.insert("-netlibDir");
00046 
00047   // Create a map of parmater keys and associated data
00048   std::map<std::string,std::string> parms;
00049   for ( i=1; i<argc; i++ ) {
00050     std::string parm(argv[i]);
00051     std::string key,value;
00052     unsigned int  eqPos = parm.find('=');
00053 
00054     // Does parm contain and '='
00055     if ( eqPos==std::string::npos ) {
00056       //Parm does not contain '='
00057       key = parm;
00058     }
00059     else {
00060       key=parm.substr(0,eqPos);
00061       value=parm.substr(eqPos+1);
00062     }
00063 
00064     // Is specifed key valid?
00065     if ( definedKeyWords.find(key) == definedKeyWords.end() ) {
00066       // invalid key word.
00067       // Write help text
00068       std::cerr <<"Undefined parameter \"" <<key <<"\".\n";
00069       std::cerr <<"Correct usage: \n";
00070       std::cerr <<"  unitTest [-mpsDir=V1] [-netlibDir=V2]\n";
00071       std::cerr <<"  where:\n";
00072       std::cerr <<"    -mpsDir: directory containing mps test files\n";
00073       std::cerr <<"        Default value V1=\"../Mps/Sample\"\n";
00074       std::cerr <<"    -netlibDir: directory containing netlib files\n";
00075       std::cerr <<"        Default value V2=\"../Mps/Netlib\"\n";
00076       return 1;
00077     }
00078     parms[key]=value;
00079   }
00080   
00081   const char dirsep =  CoinFindDirSeparator();
00082   // Set directory containing mps data files.
00083   std::string mpsDir;
00084   if (parms.find("-mpsDir") != parms.end())
00085     mpsDir=parms["-mpsDir"] + dirsep;
00086   else 
00087     mpsDir = dirsep == '/' ? "../Mps/Sample/" : "..\\Mps\\Sample\\";
00088  
00089   // Set directory containing netlib data files.
00090   std::string netlibDir;
00091   if (parms.find("-netlibDir") != parms.end())
00092     netlibDir=parms["-netlibDir"] + dirsep;
00093   else 
00094     netlibDir = dirsep == '/' ? "../Mps/Netlib/" : "..\\Mps\\Netlib\\";
00095 
00096   // *FIXME* : these tests should be written... 
00097   //  testingMessage( "Testing CoinHelperFunctions\n" );
00098   //  CoinHelperFunctionsUnitTest();
00099   //  testingMessage( "Testing CoinSort\n" );
00100   //  tripleCompareUnitTest();
00101 
00102   testingMessage( "Testing CoinError\n" );
00103   CoinErrorUnitTest();
00104 
00105   testingMessage( "Testing CoinShallowPackedVector\n" );
00106   CoinShallowPackedVectorUnitTest();
00107 
00108   testingMessage( "Testing CoinPackedVector\n" );
00109   CoinPackedVectorUnitTest();
00110 
00111   testingMessage( "Testing CoinIndexedVector\n" );
00112   CoinIndexedVectorUnitTest();
00113 
00114   testingMessage( "Testing CoinPackedMatrix\n" );
00115   CoinPackedMatrixUnitTest();
00116 
00117   
00118 // At moment CoinDenseVector is not compiling with MS V C++ V6
00119 #if 1
00120   testingMessage( "Testing CoinDenseVector\n" );
00121   //CoinDenseVectorUnitTest<int>(0);
00122   CoinDenseVectorUnitTest<double>(0.0);
00123   CoinDenseVectorUnitTest<float>(0.0f);
00124 #endif
00125 
00126 
00127   testingMessage( "Testing CoinMpsIO\n" );
00128   CoinMpsIOUnitTest(mpsDir);
00129 
00130   testingMessage( "All tests completed successfully\n" );
00131   return 0;
00132 }
00133 
00134  
00135 // Display message on stdout and stderr
00136 void testingMessage( const char * const msg )
00137 {
00138   std::cerr <<msg;
00139   //cout <<endl <<"*****************************************"
00140   //     <<endl <<msg <<endl;
00141 }
00142 

Generated on Wed Dec 3 14:34:25 2003 for Coin by doxygen 1.3.5