| 34 | } |
| 35 | |
| 36 | static void assert_throws(const std::function<void()> & fn, const std::string & expected_exception_pattern = "") { |
| 37 | try { |
| 38 | fn(); |
| 39 | } catch (const std::exception & e) { |
| 40 | if (expected_exception_pattern.empty()) { |
| 41 | return; |
| 42 | } |
| 43 | std::regex expected_exception_regex(expected_exception_pattern); |
| 44 | std::string actual_message = e.what(); |
| 45 | if (std::regex_search(actual_message, expected_exception_regex)) { |
| 46 | return; |
| 47 | } |
| 48 | throw std::runtime_error("Exception doesn't match expected pattern: " + actual_message + " (pattern: " + expected_exception_pattern + ")"); |
| 49 | throw std::runtime_error("Exception of unexpected type: " + std::string(e.what())); |
| 50 | } |
| 51 | throw std::runtime_error("Exception was expected but not thrown"); |
| 52 | } |
| 53 | |
| 54 | static void test_reasoning() { |
| 55 | //common_log_set_verbosity_thold(LOG_DEFAULT_DEBUG); |
no test coverage detected