Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2016-01-31 14:45:21 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:16:35 +0300
commit135e369313732434bec9062bb00696ee1149155e (patch)
tree8511f7566e339f7178082acdc6b60afbbf85b915 /testing
parentc00043be8c99495441bc10de8d13874c88fa13fa (diff)
Exception tests macro.
Diffstat (limited to 'testing')
-rw-r--r--testing/testing.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/testing.hpp b/testing/testing.hpp
index bb20d53b7e..5976b41dd3 100644
--- a/testing/testing.hpp
+++ b/testing/testing.hpp
@@ -80,3 +80,20 @@ CommandLineOptions const & GetTestingOptions();
::my::OnTestFailed(SRC(), ::my::impl::Message("TEST(!my::AlmostEqualULPs("#X", "#Y")", \
::my::impl::Message(X, Y), \
::my::impl::Message msg));}}
+
+// TODO(AlexZ): Add more cool macroses (or switch all unit tests to gtest).
+#define TEST_THROW(X, exception, msg) { bool expected_exception = false; \
+ try { X; } catch (exception const &) { expected_exception = true; } \
+ catch (...) { ::my::OnTestFailed(SRC(), ::my::impl::Message("Unexpected exception at TEST("#X")", \
+ ::my::impl::Message msg)); } \
+ if (!expected_exception) \
+ ::my::OnTestFailed(SRC(), ::my::impl::Message("Expected exception "#exception" was not thrown in TEST("#X")", \
+ ::my::impl::Message msg));}
+#define TEST_NO_THROW(X, msg) { \
+ try { X; } catch (...) { ::my::OnTestFailed(SRC(), ::my::impl::Message("Unexpected exception at TEST("#X")", \
+ ::my::impl::Message msg));}}
+#define TEST_ANY_THROW(X, msg) { bool was_exception = false; \
+ try { X; } catch (...) { was_exception = true; } \
+ if (!was_exception) \
+ ::my::OnTestFailed(SRC(), ::my::impl::Message("No exceptions were thrown in TEST("#X")", \
+ ::my::impl::Message msg));}