File: ThrowingTestReporter.cpp

package info (click to toggle)
etlcpp 20.40.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 18,548 kB
  • sloc: cpp: 257,359; ansic: 10,566; sh: 1,730; asm: 301; python: 281; makefile: 24
file content (61 lines) | stat: -rw-r--r-- 1,542 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "ThrowingTestReporter.h"
#include "RequiredCheckException.h"

#ifdef UNITTEST_NO_EXCEPTIONS
#include "ReportAssertImpl.h"
#endif 

namespace UnitTest {

   ThrowingTestReporter::ThrowingTestReporter(TestReporter* decoratedReporter)
      : m_decoratedReporter(decoratedReporter)
   {}

   //virtual
   ThrowingTestReporter::~ThrowingTestReporter()
   {}

   //virtual
   void ThrowingTestReporter::ReportTestStart(TestDetails const& test)
   {
      if(m_decoratedReporter)
      {
         m_decoratedReporter->ReportTestStart(test);
      }
   }

   //virtual
   void ThrowingTestReporter::ReportFailure(TestDetails const& test, char const* failure)
   {
      if(m_decoratedReporter)
      {
         m_decoratedReporter->ReportFailure(test, failure);
      }
      
      #ifndef UNITTEST_NO_EXCEPTIONS
         throw RequiredCheckException();
      #else
         static const int stopTest = 1;
         UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), stopTest);
      #endif
   }

   //virtual
   void ThrowingTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed)
   {
      if(m_decoratedReporter)
      {
         m_decoratedReporter->ReportTestFinish(test, secondsElapsed);
      }
   }

   //virtual
   void ThrowingTestReporter::ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
   {
      if(m_decoratedReporter)
      {
         m_decoratedReporter->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed);
      }
   }

}