home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / tests / Test.cc < prev    next >
C/C++ Source or Header  |  2000-06-03  |  1KB  |  55 lines

  1. //
  2. //  $Id: Test.cc,v 1.1.1.1 2000/06/02 22:22:57 sergey Exp $
  3. //
  4.  
  5. #include "Test.h"
  6.  
  7.  
  8. //==============================================================================
  9. //  Test case
  10. //==============================================================================
  11.  
  12. void Test::run(TestResult& result)
  13. {
  14.     _testResult = &result;
  15.  
  16.  #ifdef NOEXCEPTIONS
  17.     runTest();
  18.  #else
  19.     try
  20.     {
  21.         runTest();
  22.     }
  23.     catch(TestError& ex)
  24.     {
  25.         result.logError(name(), ex);
  26.     }
  27.     catch(...)
  28.     {
  29.         result.logError(name(), TestError("Unknown error", __FILE__, __LINE__));
  30.     }
  31.  #endif // NOEXCEPTIONS
  32.  
  33.     if (_errors == 0)
  34.         result.logMessage(name(), "OK");
  35. }
  36.  
  37. void Test::checkAssert(bool condition, const char* comment, const char* file, int line)
  38. {
  39.     // Currently (03.05.2000) PRC-Tools does not support the exception handling,
  40.     // this is a work around.
  41.  
  42.     if (!condition)
  43.     {
  44.         ++_errors;
  45.  
  46.  #ifdef NOEXCEPTIONS
  47.         _testResult->logError(name(), TestError(comment, file, line));
  48.  #else
  49.         throw TestError(comment, file, line);
  50.  #endif // NOEXCEPTIONS
  51.  
  52.     }
  53. }
  54.  
  55.