Changeset 481 for library/tests/mat_checks.h
- Timestamp:
- 08/06/09 13:38:17 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/mat_checks.h
r477 r481 16 16 #include "../bdm/itpp_ext.h" 17 17 #include "UnitTest++.h" 18 #include <string> 18 19 19 20 namespace UnitTest { … … 52 53 } 53 54 54 /*! CHECK_EQUAL_EX and CHECK_CLOSE_EX macros should be used only in 55 blocks having an instance of this class (which sets the globals for 56 error reporting). */ 55 /*! CHECK_*_EX macros should be used only in blocks having an instance 56 of this class (which sets the globals for error reporting). */ 57 57 class CurrentContext { 58 public: 59 // how many times to repeat a failing test before reporting 60 // failure 61 static const int max_trial_count = 3; 62 58 63 private: 59 64 static const char *config_name; … … 65 70 ~CurrentContext(); 66 71 72 /* Should be called only in blocks having an instance of 73 CurrentContext. The argument, when not default, should be 74 __LINE__ (and it is included in the returned string). 75 */ 76 static std::string format_context( int ln = -1 ); 77 67 78 template<typename Expected, typename Actual> 68 79 static void CheckEqualEx ( UnitTest::TestResults& results, … … 72 83 if ( ! ( expected == actual ) ) { 73 84 UnitTest::MemoryOutStream stream; 74 stream << "error at " << config_name << '[' << index << "]:expected " << expected << " but was " << actual;85 stream << format_context() << "expected " << expected << " but was " << actual; 75 86 76 87 results.OnTestFailure ( details, stream.GetText() ); … … 86 97 if ( !UnitTest::AreClose ( expected, actual, tolerance ) ) { 87 98 UnitTest::MemoryOutStream stream; 88 stream << "error at " << config_name << '[' << index << "]:expected " << expected << " +/- " << tolerance << " but was " << actual;99 stream << format_context() << "expected " << expected << " +/- " << tolerance << " but was " << actual; 89 100 90 101 results.OnTestFailure ( details, stream.GetText() );