| Revision 418, 1.2 kB
            (checked in by vbarta, 16 years ago) | 
        
          | 
#27: added UnitTest?++ to bdm sources, changed test_user_data to use it 
 | 
      
      
    | Line |  | 
|---|
| 1 | #include "TestResults.h" | 
|---|
| 2 | #include "TestReporter.h" | 
|---|
| 3 |  | 
|---|
| 4 | #include "TestDetails.h" | 
|---|
| 5 |  | 
|---|
| 6 | namespace UnitTest { | 
|---|
| 7 |  | 
|---|
| 8 | TestResults::TestResults(TestReporter* testReporter) | 
|---|
| 9 | : m_testReporter(testReporter) | 
|---|
| 10 | , m_totalTestCount(0) | 
|---|
| 11 | , m_failedTestCount(0) | 
|---|
| 12 | , m_failureCount(0) | 
|---|
| 13 | , m_currentTestFailed(false) | 
|---|
| 14 | { | 
|---|
| 15 | } | 
|---|
| 16 |  | 
|---|
| 17 | void TestResults::OnTestStart(TestDetails const& test) | 
|---|
| 18 | { | 
|---|
| 19 | ++m_totalTestCount; | 
|---|
| 20 | m_currentTestFailed = false; | 
|---|
| 21 | if (m_testReporter) | 
|---|
| 22 | m_testReporter->ReportTestStart(test); | 
|---|
| 23 | } | 
|---|
| 24 |  | 
|---|
| 25 | void TestResults::OnTestFailure(TestDetails const& test, char const* failure) | 
|---|
| 26 | { | 
|---|
| 27 | ++m_failureCount; | 
|---|
| 28 | if (!m_currentTestFailed) | 
|---|
| 29 | { | 
|---|
| 30 | ++m_failedTestCount; | 
|---|
| 31 | m_currentTestFailed = true; | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | if (m_testReporter) | 
|---|
| 35 | m_testReporter->ReportFailure(test, failure); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | void TestResults::OnTestFinish(TestDetails const& test, float secondsElapsed) | 
|---|
| 39 | { | 
|---|
| 40 | if (m_testReporter) | 
|---|
| 41 | m_testReporter->ReportTestFinish(test, secondsElapsed); | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | int TestResults::GetTotalTestCount() const | 
|---|
| 45 | { | 
|---|
| 46 | return m_totalTestCount; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | int TestResults::GetFailedTestCount() const | 
|---|
| 50 | { | 
|---|
| 51 | return m_failedTestCount; | 
|---|
| 52 | } | 
|---|
| 53 |  | 
|---|
| 54 | int TestResults::GetFailureCount() const | 
|---|
| 55 | { | 
|---|
| 56 | return m_failureCount; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 |  | 
|---|
| 60 | } | 
|---|