aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/main.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-10-29 10:27:20 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-10-29 10:27:20 -0400
commit006c9a5105475ce68d3009af11f41106d91e6838 (patch)
tree128465439c077b593fc9e886f6c4f63e57765faf /test/main.h
parent7d441260db2c24bd1519600cfb23143be5fe2ab0 (diff)
implement VERIFY in a function so it doesn't get compiled thousands of times.
Diffstat (limited to 'test/main.h')
-rw-r--r--test/main.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/main.h b/test/main.h
index 73f32e782..fdd382492 100644
--- a/test/main.h
+++ b/test/main.h
@@ -163,11 +163,17 @@ namespace Eigen
#include <Eigen/QR> // required for createRandomPIMatrixOfRank
-#define VERIFY(a) do { if (!(a)) { \
- std::cerr << "Test " << g_test_stack.back() << " failed in "EI_PP_MAKE_STRING(__FILE__) << " (" << EI_PP_MAKE_STRING(__LINE__) << ")" \
- << std::endl << " " << EI_PP_MAKE_STRING(a) << std::endl << std::endl; \
- abort(); \
- } } while (0)
+static void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
+{
+ if (!condition)
+ {
+ std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")" \
+ << std::endl << " " << condition_as_string << std::endl << std::endl; \
+ abort();
+ }
+}
+
+#define VERIFY(a) verify_impl(a, g_test_stack.back().c_str(), __FILE__, __LINE__, EI_PP_MAKE_STRING(a))
#define VERIFY_IS_EQUAL(a, b) VERIFY(test_is_equal(a, b))
#define VERIFY_IS_APPROX(a, b) VERIFY(test_isApprox(a, b))