40 #ifndef _testdatatools_h
41 #define _testdatatools_h
65 #define TEST(Cond, Name) Test( (Cond), (Name), Testing::Failed, Testing::Success, __FUNCTION__, __FILE__, __LINE__ );
67 #define TEST(Cond, Name) Test( (Cond), (Name), Testing::Failed, Testing::Success, __func__, __FILE__, __LINE__ );
82 T Epsilon(std::numeric_limits<T>::epsilon());
83 return Right-Epsilon*
PreciseReal(EpsilonFactor) <= Left
88 #ifndef TEST_EQUAL_EPSILON
95 #define TEST_EQUAL_EPSILON(LeftValue, RightValue, Name) Test( CompareEqualityWithEpsilon(LeftValue, RightValue), (Name), Testing::Failed, Testing::Success, __FUNCTION__, __FILE__, __LINE__ );
97 #define TEST_EQUAL_EPSILON(LeftValue, RightValue, Name) Test( CompareEqualityWithEpsilon(LeftValue, RightValue), (Name), Testing::Failed, Testing::Success, __func__, __FILE__, __LINE__ );
101 #ifndef TEST_EQUAL_MULTI_EPSILON
109 #define TEST_EQUAL_MULTI_EPSILON(LeftValue, RightValue, Name, EpsilonFactor) Test( CompareEqualityWithEpsilon(LeftValue, RightValue, EpsilonFactor), (Name), Testing::Failed, Testing::Success, __FUNCTION__, __FILE__, __LINE__ );
111 #define TEST_EQUAL_MULTI_EPSILON(LeftValue, RightValue, Name, EpsilonFactor) Test( CompareEqualityWithEpsilon(LeftValue, RightValue, EpsilonFactor), (Name), Testing::Failed, Testing::Success, __func__, __FILE__, __LINE__ );
124 #define TEST_WARN(Cond, Name) Test( (Cond), (Name), Testing::Warning, Testing::Success, __FUNCTION__, __FILE__, __LINE__ );
126 #define TEST_WARN(Cond, Name) Test( (Cond), (Name), Testing::Warning, Testing::Success, __func__, __FILE__, __LINE__ );
139 #define TEST_RESULT(ExistingResult, Name) AddTestResult( TestData( (Name), (ExistingResult), __FUNCTION__, __FILE__, __LINE__)) ;
141 #define TEST_RESULT(ExistingResult, Name) AddTestResult( TestData( (Name), (ExistingResult), __func__, __FILE__, __LINE__)) ;
156 #define TEST_THROW(ExpectThrown, CodeThatThrows, Name) \
159 AddTestResult( TestData( (Name), Testing::Failed, __FUNCTION__, __FILE__, __LINE__)) ; \
160 } catch (ExpectThrown) { \
161 AddTestResult( TestData( (Name), Testing::Success, __FUNCTION__, __FILE__, __LINE__)) ; \
163 AddTestResult( TestData( (Name), Testing::Failed, __FUNCTION__, __FILE__, __LINE__)) ; \
166 #define TEST_THROW(ExpectThrown, CodeThatThrows, Name) \
169 AddTestResult( TestData( (Name), Testing::Failed, __func__, __FILE__, __LINE__)) ; \
170 } catch (ExpectThrown) { \
171 AddTestResult( TestData( (Name), Testing::Success, __func__, __FILE__, __LINE__)) ; \
173 AddTestResult( TestData( (Name), Testing::Failed, __func__, __FILE__, __LINE__)) ; \
178 #ifndef TEST_NO_THROW
187 #define TEST_NO_THROW(CodeThatMightThrow, Name) \
189 CodeThatMightThrow; \
190 AddTestResult( TestData( (Name), Testing::Success, __FUNCTION__, __FILE__, __LINE__)) ; \
192 AddTestResult( TestData( (Name), Testing::Failed, __FUNCTION__, __FILE__, __LINE__)) ; \
195 #define TEST_NO_THROW(CodeThatMightThrow, Name) \
197 CodeThatMightThrow; \
198 AddTestResult( TestData( (Name), Testing::Success, __func__, __FILE__, __LINE__)) ; \
200 AddTestResult( TestData( (Name), Testing::Failed, __func__, __FILE__, __LINE__)) ; \
242 #define TEST_TIMED(CodeToTime, ExpectedTime, Variance, Name) \
244 TimedTest TESTDuration; \
246 MaxInt TESTLength = TESTDuration.GetLength(); \
247 MaxInt TESTTargetTime = ExpectedTime; \
248 MaxInt TESTVariance = Variance * double(ExpectedTime); \
249 if( MaxInt(TESTTargetTime-TESTVariance) < TESTLength && \
250 TESTLength < MaxInt(TESTTargetTime+TESTVariance)) \
251 { AddTestResult( TestData( (Name), Testing::Success, __FUNCTION__, __FILE__, __LINE__) ); } \
253 { AddTestResult( TestData( (Name), Testing::Failed, __FUNCTION__, __FILE__, __LINE__) ); } \
256 #define TEST_TIMED(CodeToTime, ExpectedTime, Variance, Name) \
258 TimedTest TESTDuration; \
260 MaxInt TESTLength = TESTDuration.GetLength(); \
261 MaxInt TESTTargetTime = ExpectedTime; \
262 MaxInt TESTVariance = Variance * double(ExpectedTime); \
263 if( MaxInt(TESTTargetTime-TESTVariance) < TESTLength && \
264 TESTLength < MaxInt(TESTTargetTime+TESTVariance)) \
265 { AddTestResult( TestData( (Name), Testing::Success, __func__, __FILE__, __LINE__) ); } \
267 { AddTestResult( TestData( (Name), Testing::Failed, __func__, __FILE__, __LINE__) ); } \
TestData, TestDataStorage and UnitTestGroup class definitions.
All the definitions for datatypes as well as some basic conversion functions are defined here...
Whole NowResolution()
Get the resolution of the timestamp in microseconds. This is the smallest amount of time that the Get...
TimedTest()
Simply Creating this starts the timer.
An easy way to get the time something took to execute.
MaxInt Now()
Get a timestamp, in microseconds. This will generally be some multiple of the GetTimeStampResolution ...
MaxInt GetLength()
How long since this started.
bool CompareEqualityWithEpsilon(const T &Left, const T &Right, size_t EpsilonFactor=1)
Calculate if an assumption is close enough to be considered equal.
long long MaxInt
A large integer type suitable for compile time math and long term microsecond time keeping...
The bulk of the engine components go in this namspace.
double PreciseReal
A Real number that is at least as precise as the Real and could be considerably moreso, perhaps Doubly precise. This type might be poorly aligned but very precise.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.