| Revision 418, 0.6 kB
            (checked in by vbarta, 16 years ago) | 
        
          | 
#27: added UnitTest?++ to bdm sources, changed test_user_data to use it 
 | 
      
      
    | Line |  | 
|---|
| 1 | #include "TimeConstraint.h" | 
|---|
| 2 | #include "TestResults.h" | 
|---|
| 3 | #include "MemoryOutStream.h" | 
|---|
| 4 | #include "CurrentTest.h" | 
|---|
| 5 |  | 
|---|
| 6 | namespace UnitTest { | 
|---|
| 7 |  | 
|---|
| 8 |  | 
|---|
| 9 | TimeConstraint::TimeConstraint(int ms, TestDetails const& details) | 
|---|
| 10 | : m_details(details) | 
|---|
| 11 | , m_maxMs(ms) | 
|---|
| 12 | { | 
|---|
| 13 | m_timer.Start(); | 
|---|
| 14 | } | 
|---|
| 15 |  | 
|---|
| 16 | TimeConstraint::~TimeConstraint() | 
|---|
| 17 | { | 
|---|
| 18 | double const totalTimeInMs = m_timer.GetTimeInMs(); | 
|---|
| 19 | if (totalTimeInMs > m_maxMs) | 
|---|
| 20 | { | 
|---|
| 21 | MemoryOutStream stream; | 
|---|
| 22 | stream << "Time constraint failed. Expected to run test under " << m_maxMs << | 
|---|
| 23 | "ms but took " << totalTimeInMs << "ms."; | 
|---|
| 24 |  | 
|---|
| 25 | UnitTest::CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); | 
|---|
| 26 | } | 
|---|
| 27 | } | 
|---|
| 28 |  | 
|---|
| 29 | } | 
|---|