From a956df84e04840e8f06ad8bdaeea25d4f99ea6d0 Mon Sep 17 00:00:00 2001 From: jwellbelove Date: Mon, 3 Nov 2014 12:33:46 +0000 Subject: [PATCH] Defines CHECK_NO_THROW Defines CHECK_NO_THROW if not already defined. --- test/ExtraCheckMacros.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/ExtraCheckMacros.h diff --git a/test/ExtraCheckMacros.h b/test/ExtraCheckMacros.h new file mode 100644 index 00000000..20990f06 --- /dev/null +++ b/test/ExtraCheckMacros.h @@ -0,0 +1,23 @@ +#ifndef UNITTEST_EXTRA_CHECKMACROS_H +#define UNITTEST_EXTRA_CHECKMACROS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef CHECK_NO_THROW +#define CHECK_NO_THROW(expression) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + bool caught_ = false; \ + try { expression; } \ + catch (...) { caught_ = true; } \ +if (caught_) \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Unexpected exception thrown"); \ + UNITTEST_MULTILINE_MACRO_END +#endif +#endif