You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
by the time runner::on(ut::events::assertion<TExpr>) fires, a decision on the status of test validation has already been made, without the ability to somehow intervene either before or after for completion.
As a workaround I just embed a 'predicate function' to ut::throws and ut::detail::throws_ as overriding variants.
template<class T>
void func_1(T const & e)
{
boost::ut::expect(e.code() == ex_code_1);
}
...
"test1"_test = [] {
/* some 'when' precondition */
expect(throws<some_exception>(
[] { raising_func(); },
func_1) ); // fails at func_1 body line if raising_func throws with ex_code_2
/* some other 'when' precondition */
expect(throws<some_exception>(
[] { raising_func(); },
func_2) ); // passes if raising_func throws with ex_code_2
expect((throws<some_exception>([] { throw some_exception(); })) >> fatal); // passes
expect((throws<some_exception>([] { raising_func(); })) >> fatal); // passes if raising any "some_exception" (or fail at this particular line)
expect((throws([] { throw 1; })) >> fatal); // as always!
}
And my question is: Will similar(somewhat) functionality be introduced to ut sometime?
The text was updated successfully, but these errors were encountered:
Expected Behavior
Something similar to
BOOST_REQUIRE_EXCEPTION(expression, exception_type, predicate);
In Boost.Test (at least) there is a useful opportunity to inspect exception object itself.
BOOST_REQUIRE_EXCEPTION
Actual Behavior
It seems now ut can not simulate this behaviour by overriding runner/reporter/... In the case of
expect(throws<std::runtime_error>([] { throw std::runtime_error{""}; }))
by the time
runner::on(ut::events::assertion<TExpr>)
fires, a decision on the status of test validation has already been made, without the ability to somehow intervene either before or after for completion.As a workaround I just embed a 'predicate function' to
ut::throws
andut::detail::throws_
as overriding variants.And my question is: Will similar(somewhat) functionality be introduced to ut sometime?
The text was updated successfully, but these errors were encountered: