summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uunit.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/uunit.h b/uunit.h
index c9cb258..cdb6097 100644
--- a/uunit.h
+++ b/uunit.h
@@ -66,13 +66,22 @@ public:
for(auto suite = uUnit::suite_list; suite; suite = suite->next_unit)
{
- for(auto test : suite->tests)
+ for(const auto& test : suite->tests)
{
++test_num;
try
{
- suite->setup();
- test.func();
+ try
+ {
+ suite->setup();
+ test.func();
+ }
+ catch(...)
+ {
+ // call teardown and ignore exceptions
+ try { suite->teardown(); } catch(...) {}
+ throw; // rethrow setup/test.func exception
+ }
suite->teardown();
}
catch(test_result& result)