Revision 706, 0.6 kB
(checked in by smidl, 15 years ago)
|
eol-native
|
-
Property svn:eol-style set to
native
|
Rev | Line | |
---|
[418] | 1 | #include "TimeConstraint.h" |
---|
| 2 | #include "TestResults.h" |
---|
| 3 | #include "MemoryOutStream.h" |
---|
| 4 | #include "CurrentTest.h" |
---|
| 5 | |
---|
| 6 | namespace UnitTest { |
---|
| 7 | |
---|
| 8 | |
---|
[477] | 9 | TimeConstraint::TimeConstraint ( int ms, TestDetails const& details ) |
---|
| 10 | : m_details ( details ) |
---|
| 11 | , m_maxMs ( ms ) { |
---|
| 12 | m_timer.Start(); |
---|
[418] | 13 | } |
---|
| 14 | |
---|
[477] | 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."; |
---|
[418] | 21 | |
---|
[477] | 22 | UnitTest::CurrentTest::Results()->OnTestFailure ( m_details, stream.GetText() ); |
---|
| 23 | } |
---|
[418] | 24 | } |
---|
| 25 | |
---|
| 26 | } |
---|