?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #ifndef UNITTEST_SCOPEDCURRENTTEST_H
  2. #define UNITTEST_SCOPEDCURRENTTEST_H
  3.  
  4. #include "UnitTest++/CurrentTest.h"
  5. #include <cstddef>
  6.  
  7. class ScopedCurrentTest
  8. {
  9. public:
  10.    ScopedCurrentTest()
  11.       : m_oldTestResults(UnitTest::CurrentTest::Results())
  12.       , m_oldTestDetails(UnitTest::CurrentTest::Details())
  13.    {}
  14.  
  15.    explicit ScopedCurrentTest(UnitTest::TestResults& newResults, const UnitTest::TestDetails* newDetails = NULL)
  16.       : m_oldTestResults(UnitTest::CurrentTest::Results())
  17.       , m_oldTestDetails(UnitTest::CurrentTest::Details())
  18.    {
  19.       UnitTest::CurrentTest::Results() = &newResults;
  20.  
  21.       if (newDetails != NULL)
  22.       {
  23.          UnitTest::CurrentTest::Details() = newDetails;
  24.       }
  25.    }
  26.  
  27.    ~ScopedCurrentTest()
  28.    {
  29.       UnitTest::CurrentTest::Results() = m_oldTestResults;
  30.       UnitTest::CurrentTest::Details() = m_oldTestDetails;
  31.    }
  32.  
  33. private:
  34.    UnitTest::TestResults* m_oldTestResults;
  35.    const UnitTest::TestDetails* m_oldTestDetails;
  36. };
  37.  
  38. #endif
  39.