1 #ifndef UNITTEST_TIMECONSTRAINT_H
2 #define UNITTEST_TIMECONSTRAINT_H
3 
4 #include "TimeHelpers.h"
5 #include "HelperMacros.h"
6 
7 namespace UnitTest {
8 
9 class TestResults;
10 class TestDetails;
11 
12 class UNITTEST_LINKAGE TimeConstraint
13 {
14 public:
15     TimeConstraint(int ms, TestDetails const& details);
16     ~TimeConstraint();
17 
18 private:
19     void operator=(TimeConstraint const&);
20 	TimeConstraint(TimeConstraint const&);
21 
22 	Timer m_timer;
23     TestDetails const& m_details;
24 	int const m_maxMs;
25 };
26 
27 #define UNITTEST_TIME_CONSTRAINT(ms) \
28 	UnitTest::TimeConstraint unitTest__timeConstraint__(ms, UnitTest::TestDetails(m_details, __LINE__))
29 
30 #define UNITTEST_TIME_CONSTRAINT_EXEMPT() \
31 	UNITTEST_MULTILINE_MACRO_BEGIN \
32 	m_details.timeConstraintExempt = true; \
33 	UNITTEST_MULTILINE_MACRO_END
34 
35 }
36 
37 #endif
38