diff --git a/tests/helpers/assertions.hpp b/tests/helpers/assertions.hpp index 54f700a2..18bcaa03 100644 --- a/tests/helpers/assertions.hpp +++ b/tests/helpers/assertions.hpp @@ -3,26 +3,55 @@ #include #include -#define xlnt_assert(expression) do\ - {\ - try { if (expression) break; }\ - catch (...) {}\ - throw xlnt::exception("test failed");\ +#define XLNT_STRINGIFYX(x) #x +#define XLNT_STRINGIFY(x) XLNT_STRINGIFYX(x) + +#define xlnt_assert(expression) \ + do \ + { \ + try \ + { \ + if (expression) break; \ + } \ + catch (std::exception & ex) \ + { \ + throw ex; \ + } \ + catch (...) \ + { \ + } \ + throw xlnt::exception("test failed -> " XLNT_STRINGIFY(expression)); \ } while (false) -#define xlnt_assert_throws_nothing(expression) do\ - {\ - try { expression; break; }\ - catch (...) {}\ - throw xlnt::exception("test failed");\ +#define xlnt_assert_throws_nothing(expression) \ + do \ + { \ + try \ + { \ + expression; \ + break; \ + } \ + catch (...) \ + { \ + } \ + throw xlnt::exception("test failed -> " XLNT_STRINGIFY(expression)); \ } while (false) -#define xlnt_assert_throws(expression, exception_type) do\ - {\ - try { expression; }\ - catch (exception_type) { break; }\ - catch (...) {}\ - throw xlnt::exception("test failed");\ +#define xlnt_assert_throws(expression, exception_type) \ + do \ + { \ + try \ + { \ + expression; \ + } \ + catch (exception_type) \ + { \ + break; \ + } \ + catch (...) \ + { \ + } \ + throw xlnt::exception("test failed -> " XLNT_STRINGIFY(expression)); \ } while (false) #define xlnt_assert_equals(left, right) xlnt_assert(left == right) diff --git a/tests/helpers/test_suite.hpp b/tests/helpers/test_suite.hpp index 7de32f6e..6083b052 100644 --- a/tests/helpers/test_suite.hpp +++ b/tests/helpers/test_suite.hpp @@ -39,9 +39,18 @@ public: std::cout << "."; status.tests_passed++; } + catch (std::exception &ex) + { + std::cout << "*\n" + << test.second << " failed with:\n" + << ex.what() << '\n'; + status.tests_failed++; + status.failures.push_back(test.second); + } catch (...) { - std::cout << "*"; + std::cout << "*\n" + << test.second << " failed" << '\n'; status.tests_failed++; status.failures.push_back(test.second); }