catch all exceptions in unit tester
This commit is contained in:
parent
27bc7be245
commit
37def859e5
|
@ -81,7 +81,7 @@ static bool test_case_##module##_##__LINE__ = \
|
||||||
* be able to see how many tests of the module succeeded and how many
|
* be able to see how many tests of the module succeeded and how many
|
||||||
* failed.
|
* failed.
|
||||||
*
|
*
|
||||||
* @see ostd::test::fail_if_not()
|
* @see ostd::test::fail(), ostd::test::fail_if_not()
|
||||||
*/
|
*/
|
||||||
void fail_if(bool b) {
|
void fail_if(bool b) {
|
||||||
if (b) {
|
if (b) {
|
||||||
|
@ -99,6 +99,16 @@ void fail_if_not(bool b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Makes the test fail.
|
||||||
|
*
|
||||||
|
* The current test will exit.
|
||||||
|
*
|
||||||
|
* @see ostd::test::fail_if()
|
||||||
|
*/
|
||||||
|
void fail() {
|
||||||
|
throw detail::test_error{};
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Runs all enabled test cases.
|
/** @brief Runs all enabled test cases.
|
||||||
*
|
*
|
||||||
* @returns An std::pair containing the number of tests that succeeded
|
* @returns An std::pair containing the number of tests that succeeded
|
||||||
|
@ -112,6 +122,10 @@ std::pair<std::size_t, std::size_t> run() {
|
||||||
} catch (detail::test_error) {
|
} catch (detail::test_error) {
|
||||||
++fail;
|
++fail;
|
||||||
continue;
|
continue;
|
||||||
|
} catch (...) {
|
||||||
|
std::printf("warning: uncaught exception");
|
||||||
|
++fail;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
++succ;
|
++succ;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue