throws_op Struct Template
Operator struct to check if an expression throws any exception. More...
Declaration
Included Headers
Base struct
| struct | callable_op |
|
Common base struct for callable-wrapping operators. More... | |
Public Member Typedefs Index
| using | op_type = op |
|
Marker identifying the framework expression types. More... | |
Public Constructors Index
template <class Callable_T> | |
| throws_op (Callable_T &&func) | |
|
Constructs an exception checking operator for the given callable. More... | |
Public Operators Index
| constexpr | operator bool () const |
|
Conversion operator to boolean. More... | |
Public Member Functions Index
| throw_outcome | outcome (void) const noexcept |
|
Retrieves what the invocation threw. More... | |
| const std::string & | what (void) const noexcept |
Private Member Attributes Index
| throw_outcome | outcome_ |
|
Stores what the invocation threw, when the check failed. More... | |
| const bool | value_ |
|
Stores the result of the callable invocation. More... | |
| std::string | what_ |
|
Stores the what() of the std::exception thrown, when the check failed. More... | |
Description
Operator struct to check if an expression throws any exception.
This explicit specialisation checks whether invoking the given callable throws any exception, regardless of type. The check is performed at construction time, with the result cached for reporting and composition. Use this when a test must verify that an operation raises an exception without caring about the specific exception type.
Definition at line 1529 of file detail.h.
Public Member Typedefs
op_type
|
Marker identifying the framework expression types.
Detected by the extension::is_op concept, and inherited by all types derived from op.
Definition at line 128 of file extension.h.
Public Constructors
throws_op()
| explicit |
Constructs an exception checking operator for the given callable.
- Template Parameters
-
Callable_T The type of the callable object to be invoked; it must be invocable without arguments, as an lvalue, so a mutable lambda is accepted.
- Parameters
-
func The callable object to be invoked.
Invokes func inside a try/catch block. If func throws any exception the result is true; if no exception is thrown the result is false. The result is passed to the callable_op base class constructor.
The failed_requirement thrown to stop the test case after a failed require() in func is not an exception of func, and is rethrown.
Declaration at line 1542 of file detail.h, definition at line 1236 of file detail-inlines.h.
References micro_os_plus::micro_test_plus::detail::callable_op::callable_op, micro_os_plus::micro_test_plus::detail::throws_op< Exception_T >::throws_op and micro_os_plus::micro_test_plus::detail::none.
Public Operators
operator bool()
| nodiscard constexpr |
Conversion operator to boolean.
- Parameters
None.
- Returns
The result of the callable invocation.
Returns the result computed by the constructor of the derived operator; the callable is not invoked again.
Declaration at line 1420 of file detail.h, definition at line 1137 of file detail-inlines.h.
Public Member Functions
outcome()
| inline nodiscard noexcept |
Retrieves what the invocation threw.
- Parameters
None.
- Returns
The kind of the exception thrown, throw_outcome::none if the callable completed, or if the expected exception was thrown.
Returns what was recorded when the check failed.
Declaration at line 1432 of file detail.h, definition at line 1147 of file detail-inlines.h.
what()
| inline nodiscard noexcept |
Retrieves the what() of the std::exception thrown.
- Parameters
None.
- Returns
The text, empty unless the outcome is throw_outcome::std_exception.
Returns the text recorded when a std::exception was thrown.
Declaration at line 1443 of file detail.h, definition at line 1157 of file detail-inlines.h.
Private Member Attributes
outcome_
|
Stores what the invocation threw, when the check failed.
Copied from the callable_result by the constructor.
value_
|
what_
|
The documentation for this struct was generated from the following files:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.