catch(...)//If we end up here, but we wanted to catch a specific Exception, we consider this failed, but if Exception is AnyExpection, we pass.
{
returnstd::is_same_v<Exception,AnyException>;
}
// If we end up here we didn't catch any exception. Thus, if this is on purpose, i.e. 'Exception= NoException', we return true.
returnstd::is_same_v<Exception,NoException>;
}
public:
/**
* \brief Checks that the expression throws
*
* This will throw an exception if the check fails and if the AlwaysThrow policy was used on creation.
* \param expr A nullary functor that is expected to throw an exception on evaluation that is of type `Exception` or any exception if the template parameter is omitted.
* \param name A name to identify this check. Defaults to ""
* \returns A CollectorStream that can be used to create a diagnostic message to be printed on failure.
* \par Example:
* \code
* checkThrow<Exception>([]{ throw Exception; }, "Expected an 'Exception' to be thrown");
* checkThrow([]{ throw std::runtime_Error("error"); }, "Expected any exception to be thrown");
* This will throw an exception if the check fails.
*
* \param expr A nullary functor that is expected to throw an exception on evaluation that is of type `Exception` or any exception if the template parameter is omitted.
* \param name A name to identify this check. Defaults to ""
* \returns A CollectorStream that can be used to create a diagnostic message to be printed on failure.
* \par Example:
* \code
* requireThrow<Exception>([]{ throw Exception; }, "Expected an 'Exception' to be thrown");
* requireThrow([]{ throw std::runtime_Error("error"); }, "Expected any exception to be thrown");