TestConfigOptions.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #include "../include/TestConfigOptions.h"
00029 #include "../../include/PCMFileSystemManager.h"
00030 
00031 namespace ParCompMarkTest
00032 {
00033 
00034   void TestConfigOptions::setUp()
00035   {
00036         std::string currentLogFile = "logs/TestConfigOptions.log";
00037 
00038         if(Logger::getInstance() && Logger::getInstance()->getLogFileName() != currentLogFile)
00039          Logger::destroyInstance();
00040 
00041         if(!FileSystemManager::getInstance())
00042         {
00043          FileSystemManager::createInstance();
00044          FileSystemManager::getInstance()->setAppDirectory("./");
00045          FileSystemManager::getInstance()->initialize();
00046         }
00047 
00048         if(!Logger::getInstance())
00049         {
00050          Logger::createInstance();
00051          Logger::getInstance()->setLogFileName(currentLogFile);
00052          Logger::getInstance()->initialize();
00053         }
00054   }
00055 
00056  /*----------------------------------------------------------------------*/
00057 
00058   void TestConfigOptions::tearDown()
00059   {
00060   }
00061 
00062  /*----------------------------------------------------------------------*/
00063 
00064   //
00065   // Constructor & destructor tests
00066   //
00067 
00068   void TestConfigOptions::test_constructor()
00069   {
00070         ConfigOptions::Pointer options;
00071         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00072   }
00073 
00074  /*----------------------------------------------------------------------*/
00075 
00076   void TestConfigOptions::test_destructor()
00077   {
00078         // Tested at constructor
00079   }
00080 
00081  /*----------------------------------------------------------------------*/
00082 
00083   //
00084   // Method tests
00085   //
00086 
00087   void TestConfigOptions::test_initialize()
00088   {
00089 
00090         /*
00091          * You have to verify the following:
00092          * 
00093          * Initialize option container.
00094          */
00095 
00096         ConfigOptions::Pointer options;
00097         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00098         CPPUNIT_ASSERT_NO_THROW(options->initialize());
00099   }
00100 
00101  /*----------------------------------------------------------------------*/
00102 
00103   void TestConfigOptions::test_finalize()
00104   {
00105 
00106         /*
00107          * You have to verify the following:
00108          * 
00109          * Finalize option container.
00110          */
00111 
00112         // Tested a initialize
00113   }
00114 
00115  /*----------------------------------------------------------------------*/
00116 
00117   void TestConfigOptions::test_hasOption_cstd__string()
00118   {
00119 
00120         /*
00121          * You have to verify the following:
00122          * 
00123          * Check for option.
00124          */
00125 
00126         ConfigOptions::Pointer options;
00127         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00128         CPPUNIT_ASSERT_NO_THROW(options->initialize());
00129 
00130         // False negative
00131         CPPUNIT_ASSERT(!options->hasOption("something"));
00132 
00133         // True positive
00134         s32 val = 1234;
00135 
00136         CPPUNIT_ASSERT_NO_THROW(options->setValue("something", &val, ConfigOptions::INTEGER, ""));
00137         CPPUNIT_ASSERT(options->hasOption("something"));
00138 
00139         // False negative
00140         CPPUNIT_ASSERT_NO_THROW(options->removeOption("something"));
00141         CPPUNIT_ASSERT(!options->hasOption("something"));
00142   }
00143 
00144  /*----------------------------------------------------------------------*/
00145 
00146   void TestConfigOptions::test_getString_cstd__string()
00147   {
00148 
00149         /*
00150          * You have to verify the following:
00151          * 
00152          * Get option.
00153          */
00154 
00155         ConfigOptions::Pointer options;
00156         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00157         CPPUNIT_ASSERT_NO_THROW(options->initialize());
00158 
00159         // False negative
00160         CPPUNIT_ASSERT_THROW(options->getString("something"), ParCompMark::Exception);
00161 
00162         // True positive
00163         CPPUNIT_ASSERT_NO_THROW(options->setString("something", "stuff"));
00164         CPPUNIT_ASSERT(options->getString("something") == "stuff");
00165 
00166         // False negative
00167         CPPUNIT_ASSERT_NO_THROW(options->removeOption("something"));
00168         CPPUNIT_ASSERT_THROW(options->getString("something"), ParCompMark::Exception);
00169   }
00170 
00171  /*----------------------------------------------------------------------*/
00172 
00173   void TestConfigOptions::test_getBool_cstd__string()
00174   {
00175 
00176         /*
00177          * You have to verify the following:
00178          * 
00179          * Get option.
00180          */
00181 
00182         ConfigOptions::Pointer options;
00183         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00184         CPPUNIT_ASSERT_NO_THROW(options->initialize());
00185 
00186         // False negative
00187         CPPUNIT_ASSERT_THROW(options->getBool("something"), ParCompMark::Exception);
00188 
00189         // True positive
00190         CPPUNIT_ASSERT_NO_THROW(options->setBool("something", true));
00191         CPPUNIT_ASSERT(options->getBool("something") == true);
00192 
00193         // False negative
00194         CPPUNIT_ASSERT_NO_THROW(options->removeOption("something"));
00195         CPPUNIT_ASSERT_THROW(options->getBool("something"), ParCompMark::Exception);
00196   }
00197 
00198  /*----------------------------------------------------------------------*/
00199 
00200   void TestConfigOptions::test_getInteger_cstd__string()
00201   {
00202 
00203         /*
00204          * You have to verify the following:
00205          * 
00206          * Get option.
00207          */
00208 
00209         ConfigOptions::Pointer options;
00210         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00211         CPPUNIT_ASSERT_NO_THROW(options->initialize());
00212 
00213         // False negative
00214         CPPUNIT_ASSERT_THROW(options->getInteger("something"), ParCompMark::Exception);
00215 
00216         // True positive
00217         CPPUNIT_ASSERT_NO_THROW(options->setInteger("something", 12345));
00218         CPPUNIT_ASSERT(options->getInteger("something") == 12345);
00219 
00220         // False negative
00221         CPPUNIT_ASSERT_NO_THROW(options->removeOption("something"));
00222         CPPUNIT_ASSERT_THROW(options->getInteger("something"), ParCompMark::Exception);
00223   }
00224 
00225  /*----------------------------------------------------------------------*/
00226 
00227   void TestConfigOptions::test_getReal_cstd__string()
00228   {
00229 
00230         /*
00231          * You have to verify the following:
00232          * 
00233          * Get option.
00234          */
00235 
00236         ConfigOptions::Pointer options;
00237         CPPUNIT_ASSERT_NO_THROW(options = new ConfigOptions());
00238         CPPUNIT_ASSERT_NO_THROW(options->initialize());
00239 
00240         // False negative
00241         CPPUNIT_ASSERT_THROW(options->getReal("something"), ParCompMark::Exception);
00242 
00243         // True positive
00244         CPPUNIT_ASSERT_NO_THROW(options->setReal("something", 1.2345));
00245         CPPUNIT_ASSERT(options->getReal("something") == 1.2345);
00246 
00247         // False negative
00248         CPPUNIT_ASSERT_NO_THROW(options->removeOption("something"));
00249         CPPUNIT_ASSERT_THROW(options->getReal("something"), ParCompMark::Exception);
00250   }
00251 
00252  /*----------------------------------------------------------------------*/
00253 
00254   void TestConfigOptions::test_testString_cstd__string_cstd__string()
00255   {
00256 
00257         /*
00258          * You have to verify the following:
00259          * 
00260          * Return true if the option exists with the given name and equals to the given value.
00261          */
00262 
00263         CPPUNIT_FAIL("Implement this test!");
00264   }
00265 
00266  /*----------------------------------------------------------------------*/
00267 
00268   void TestConfigOptions::test_setString_cstd__string_cstd__string_cstd__string()
00269   {
00270 
00271         /*
00272          * You have to verify the following:
00273          * 
00274          * Set option.
00275          */
00276 
00277         // Tested at getter
00278   }
00279 
00280  /*----------------------------------------------------------------------*/
00281 
00282   void TestConfigOptions::test_setBool_cstd__string_cbool_cstd__string()
00283   {
00284 
00285         /*
00286          * You have to verify the following:
00287          * 
00288          * Set option.
00289          */
00290 
00291         // Tested at getter
00292   }
00293 
00294  /*----------------------------------------------------------------------*/
00295 
00296   void TestConfigOptions::test_setInteger_cstd__string_cs32_cstd__string()
00297   {
00298 
00299         /*
00300          * You have to verify the following:
00301          * 
00302          * Set option.
00303          */
00304 
00305         // Tested at getter
00306   }
00307 
00308  /*----------------------------------------------------------------------*/
00309 
00310   void TestConfigOptions::test_setReal_cstd__string_cReal_cstd__string()
00311   {
00312 
00313         /*
00314          * You have to verify the following:
00315          * 
00316          * Set option.
00317          */
00318 
00319         // Tested at getter
00320   }
00321 
00322  /*----------------------------------------------------------------------*/
00323 
00324   void TestConfigOptions::test_removeOption_cstd__string()
00325   {
00326 
00327         /*
00328          * You have to verify the following:
00329          * 
00330          * Remove option.
00331          */
00332 
00333         // Tested above
00334   }
00335 
00336  /*----------------------------------------------------------------------*/
00337 
00338   void TestConfigOptions::test_saveToIniFile_cstd__string()
00339   {
00340 
00341         /*
00342          * You have to verify the following:
00343          * 
00344          * Create user-level ini file in the application directory (existing file will be overwritten).
00345          */
00346 
00347         CPPUNIT_FAIL("Implement this test!");
00348   }
00349 
00350  /*----------------------------------------------------------------------*/
00351 
00352   void TestConfigOptions::test_loadFromIniFile_cstd__string()
00353   {
00354 
00355         /*
00356          * You have to verify the following:
00357          * 
00358          * Load user-level ini file.
00359          */
00360 
00361         CPPUNIT_FAIL("Implement this test!");
00362   }
00363 
00364  /*----------------------------------------------------------------------*/
00365 
00366   void TestConfigOptions::test_getValue_cstd__string_cConfigOptions__OptionType()
00367   {
00368 
00369         /*
00370          * You have to verify the following:
00371          * 
00372          * Get option value for the specified type (internal method).
00373          */
00374 
00375         // Tested above
00376   }
00377 
00378  /*----------------------------------------------------------------------*/
00379 
00380   void TestConfigOptions::test_setValue_cstd__string_cvoid_p_cConfigOptions__OptionType_cstd__string()
00381   {
00382 
00383         /*
00384          * You have to verify the following:
00385          * 
00386          * Set option value for the specified type (internal method).
00387          */
00388 
00389         // Tested above
00390   }
00391 
00392  /*----------------------------------------------------------------------*/
00393 
00394   void TestConfigOptions::test_getOptionTypeSize_cConfigOptions__OptionType()
00395   {
00396 
00397         /*
00398          * You have to verify the following:
00399          * 
00400          * Get size of option type
00401          */
00402 
00403         // Tested above
00404   }
00405 
00406  /*----------------------------------------------------------------------*/
00407 
00408   void TestConfigOptions::test_optionToString_ConfigOptions__Option__Pointer()
00409   {
00410 
00411         /*
00412          * You have to verify the following:
00413          * 
00414          * Give string representation of the option value
00415          */
00416 
00417         CPPUNIT_FAIL("Implement this test!");
00418   }
00419 
00420  /*----------------------------------------------------------------------*/
00421 
00422   // To register the suite we add:
00424   CPPUNIT_TEST_SUITE_REGISTRATION(TestConfigOptions);
00425 }