root/library/tests/unittest-cpp/TimeConstraint.cpp @ 486

Revision 477, 0.6 kB (checked in by mido, 15 years ago)

panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc

Line 
1#include "TimeConstraint.h"
2#include "TestResults.h"
3#include "MemoryOutStream.h"
4#include "CurrentTest.h"
5
6namespace UnitTest {
7
8
9TimeConstraint::TimeConstraint ( int ms, TestDetails const& details )
10                : m_details ( details )
11                , m_maxMs ( ms ) {
12        m_timer.Start();
13}
14
15TimeConstraint::~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}
Note: See TracBrowser for help on using the browser.