| 84 | virtual bool postTest(bool) { return true; } |
| 85 | |
| 86 | bool execTest(std::pair<std::string, bool (subclass_t::*)()> const& testRef, unsigned int iterations) |
| 87 | { |
| 88 | std::printf("%s::%s... \n", demangle_type_name(typeid(subclass_t).name()).c_str(), testRef.first.c_str()); |
| 89 | |
| 90 | bool result = true; |
| 91 | for (unsigned int i = 0; result && i != iterations; ++i) { |
| 92 | result = preTest(); |
| 93 | try { |
| 94 | result = result && (static_cast<subclass_t*>(this)->*testRef.second)(); |
| 95 | } |
| 96 | catch (...) { |
| 97 | std::printf(" FAILED!\n ******* Unhandled exception thrown\n\n"); |
| 98 | result = false; |
| 99 | } |
| 100 | result = postTest(result) && result; |
| 101 | } |
| 102 | |
| 103 | if (result) { |
| 104 | std::printf(" passed\n\n"); |
| 105 | } |
| 106 | return result; |
| 107 | } |
| 108 | |
| 109 | private: |
| 110 | static std::string demangle_type_name(const char* name) |