From 6b379c7137fcc27622f0698063c802982a54c7b8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 19 Jan 2009 09:30:38 +0000 Subject: [PATCH] catch exceptions from TEST_CHECK --- test/test.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/test.hpp b/test/test.hpp index cabf1e618..609685350 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -52,8 +52,19 @@ void report_failure(char const* str, char const* file, int line); report_failure(x, line, file) #define TEST_CHECK(x) \ - if (!(x)) \ - TEST_REPORT_AUX("TEST_CHECK failed: \"" #x "\"", __FILE__, __LINE__) + try \ + { \ + if (!(x)) \ + TEST_REPORT_AUX("TEST_CHECK failed: \"" #x "\"", __FILE__, __LINE__); \ + } \ + catch (std::exception& e) \ + { \ + TEST_ERROR("Exception thrown: " #x " :" + std::string(e.what())); \ + } \ + catch (...) \ + { \ + TEST_ERROR("Exception thrown: " #x); \ + } #define TEST_ERROR(x) \ TEST_REPORT_AUX((std::string("ERROR: \"") + x + "\"").c_str(), __FILE__, __LINE__)