?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #ifndef UNITTEST_EXECUTE_TEST_H
  2. #define UNITTEST_EXECUTE_TEST_H
  3.  
  4. #include "Config.h"
  5. #include "ExceptionMacros.h"
  6. #include "TestDetails.h"
  7. #include "TestResults.h"
  8. #include "MemoryOutStream.h"
  9. #include "AssertException.h"
  10. #include "RequiredCheckException.h"
  11. #include "CurrentTest.h"
  12.  
  13. #ifdef UNITTEST_NO_EXCEPTIONS
  14. #include "ReportAssertImpl.h"
  15. #endif
  16.  
  17. #ifdef UNITTEST_POSIX
  18. #include "Posix/SignalTranslator.h"
  19. #endif
  20.  
  21. namespace UnitTest {
  22.  
  23.    template< typename T >
  24.    void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest)
  25.    {
  26.       if (isMockTest == false)
  27.          CurrentTest::Details() = &details;
  28.  
  29. #ifdef UNITTEST_NO_EXCEPTIONS
  30.       if (UNITTEST_SET_ASSERT_JUMP_TARGET() == 0)
  31.       {
  32. #endif
  33. #ifndef UNITTEST_POSIX
  34.       UNITTEST_IMPL_TRY({ testObject.RunImpl(); })
  35. #else
  36.       UNITTEST_IMPL_TRY
  37.          ({
  38.          UNITTEST_THROW_SIGNALS_POSIX_ONLY
  39.          testObject.RunImpl();
  40.       })
  41. #endif
  42.       UNITTEST_IMPL_CATCH(RequiredCheckException, e, { (void)e; })
  43.       UNITTEST_IMPL_CATCH(AssertException, e, { (void)e; })
  44.       UNITTEST_IMPL_CATCH(std::exception, e,
  45.       {
  46.          MemoryOutStream stream;
  47.          stream << "Unhandled exception: " << e.what();
  48.          CurrentTest::Results()->OnTestFailure(details, stream.GetText());
  49.       })
  50.       UNITTEST_IMPL_CATCH_ALL
  51.          ({
  52.          CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: test crashed");
  53.       })
  54. #ifdef UNITTEST_NO_EXCEPTIONS
  55.    }
  56. #endif
  57.    }
  58.  
  59. }
  60.  
  61. #endif
  62.