Changeset 465 for library/tests/mat_checks.h
- Timestamp:
- 08/03/09 08:09:16 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/mat_checks.h
r456 r465 22 22 bool AreClose(const itpp::vec &expected, const itpp::vec &actual, 23 23 double tolerance); 24 25 bool AreClose(const itpp::vec &expected, const itpp::vec &actual, 26 const itpp::vec &tolerance); 24 27 25 28 bool AreClose(const itpp::mat &expected, const itpp::mat &actual, … … 50 53 } 51 54 52 /*! CHECK_ CLOSE_EX macro should be used only in blocks having an53 instance of this class (which sets the globals for error54 reporting). */55 /*! CHECK_EQUAL_EX and CHECK_CLOSE_EX macros should be used only in 56 blocks having an instance of this class (which sets the globals for 57 error reporting). */ 55 58 class CurrentContext 56 59 { … … 64 67 ~CurrentContext(); 65 68 66 template< typename Expected, typename Actual, typename Tolerance > 69 template<typename Expected, typename Actual> 70 static void CheckEqualEx(UnitTest::TestResults& results, 71 Expected const& expected, 72 Actual const& actual, 73 UnitTest::TestDetails const& details) { 74 if (!(expected == actual)) { 75 UnitTest::MemoryOutStream stream; 76 stream << "error at " << config_name << '[' << index << "]: expected " << expected << " but was " << actual; 77 78 results.OnTestFailure(details, stream.GetText()); 79 } 80 } 81 82 template<typename Expected, typename Actual, typename Tolerance> 67 83 static void CheckCloseEx(UnitTest::TestResults& results, 68 84 Expected const& expected, … … 79 95 }; 80 96 97 #define CHECK_EQUAL_EX(expected, actual) \ 98 do \ 99 { \ 100 try { \ 101 CurrentContext::CheckEqualEx(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), 0, false)); \ 102 } \ 103 catch (...) { \ 104 UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ 105 "Unhandled exception in CHECK_EQUAL_EX(" #expected ", " #actual ")"); \ 106 } \ 107 } while (0) 108 109 81 110 #define CHECK_CLOSE_EX(expected, actual, tolerance) \ 82 111 do \ … … 87 116 catch (...) { \ 88 117 UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ 89 "Unhandled exception in CHECK_CLOSE (" #expected ", " #actual ")"); \118 "Unhandled exception in CHECK_CLOSE_EX(" #expected ", " #actual ")"); \ 90 119 } \ 91 120 } while (0)