Mercurial > fife-parpg
comparison ext/UnitTest++/src/TimeConstraint.cpp @ 37:0d325e9d5953
added unittest++ files into ext. Not hooked into build scripts yet
author | jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 12 Jul 2008 12:00:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
36:6f1227f4932b | 37:0d325e9d5953 |
---|---|
1 #include "TimeConstraint.h" | |
2 #include "TestResults.h" | |
3 #include "MemoryOutStream.h" | |
4 | |
5 namespace UnitTest { | |
6 | |
7 | |
8 TimeConstraint::TimeConstraint(int ms, TestResults& result, TestDetails const& details) | |
9 : m_result(result) | |
10 , m_details(details) | |
11 , m_maxMs(ms) | |
12 { | |
13 m_timer.Start(); | |
14 } | |
15 | |
16 TimeConstraint::~TimeConstraint() | |
17 { | |
18 int 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 m_result.OnTestFailure(m_details, stream.GetText()); | |
25 } | |
26 } | |
27 | |
28 } |