|
Revision 706, 0.6 kB
(checked in by smidl, 16 years ago)
|
|
eol-native
|
-
Property svn:eol-style set to
native
|
| 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 | m_timer.Start(); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | TimeConstraint::~TimeConstraint() { |
|---|
| 16 | double const totalTimeInMs = m_timer.GetTimeInMs(); |
|---|
| 17 | if ( totalTimeInMs > m_maxMs ) { |
|---|
| 18 | MemoryOutStream stream; |
|---|
| 19 | stream << "Time constraint failed. Expected to run test under " << m_maxMs << |
|---|
| 20 | "ms but took " << totalTimeInMs << "ms."; |
|---|
| 21 | |
|---|
| 22 | UnitTest::CurrentTest::Results()->OnTestFailure ( m_details, stream.GetText() ); |
|---|
| 23 | } |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | } |
|---|