micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::callable_op Struct Reference

Common base struct for callable-wrapping operators. More...

#include "micro-os-plus/micro-test-plus.h"

Inheritance diagram for micro_os_plus::micro_test_plus::detail::callable_op:

Public Types

using op_type = op
 Marker identifying the framework expression types.

Public Member Functions

 callable_op (callable_result &&result)
 Constructs a callable operator with the pre-computed result.
constexpr operator bool () const
 Conversion operator to boolean.
throw_outcome outcome (void) const noexcept
 Retrieves what the invocation threw.
const std::string & what (void) const noexcept
 Retrieves the what() of the std::exception thrown.

Private Attributes

throw_outcome outcome_ { throw_outcome::none }
 Stores what the invocation threw, when the check failed.
const bool value_ {}
 Stores the result of the callable invocation.
std::string what_ {}
 Stores the what() of the std::exception thrown, when the check failed.

Detailed Description

The base of the exception-checking operators, throws_op and nothrow_op, which invoke the callable in their constructors. It stores the pre-computed boolean result, and, when the check failed, what was thrown, so that the report can state why (see expression_formatter::append_throw_reason()).

Definition at line 1402 of file detail.h.

Member Typedef Documentation

◆ op_type

Detected by the extension::is_op concept, and inherited by all types derived from op.

Definition at line 128 of file extension.h.

Constructor & Destructor Documentation

◆ callable_op()

micro_os_plus::micro_test_plus::detail::callable_op::callable_op ( callable_result && result)
inlineexplicit
Parameters
resultThe result of the invocation, with what was thrown.

Stores the pre-computed boolean result, and, when the check failed, what the invocation threw and the what() of the exception.

Definition at line 1125 of file detail-inlines.h.

1127 : value_{ result.value }, outcome_{ result.outcome },
1128 what_{ std::move (result.what) }
1129 {
std::string what_
Stores the what() of the std::exception thrown, when the check failed.
Definition detail.h:1471
throw_outcome outcome_
Stores what the invocation threw, when the check failed.
Definition detail.h:1461
const bool value_
Stores the result of the callable invocation.
Definition detail.h:1453

References outcome(), outcome_, value_, what(), and what_.

Referenced by micro_os_plus::micro_test_plus::detail::nothrow_op::nothrow_op(), micro_os_plus::micro_test_plus::detail::throws_op< Exception_T >::throws_op(), and micro_os_plus::micro_test_plus::detail::throws_op< void >::throws_op().

Member Function Documentation

◆ operator bool()

micro_os_plus::micro_test_plus::detail::callable_op::operator bool ( ) const
nodiscardconstexpr
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.

Definition at line 1136 of file detail-inlines.h.

1139 {
1140 return value_;

References value_.

◆ outcome()

throw_outcome micro_os_plus::micro_test_plus::detail::callable_op::outcome ( void ) const
inlinenodiscardnoexcept
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.

Definition at line 1147 of file detail-inlines.h.

1149 {
1150 return outcome_;

References outcome_.

Referenced by callable_op().

◆ what()

const std::string & micro_os_plus::micro_test_plus::detail::callable_op::what ( void ) const
inlinenodiscardnoexcept
Parameters
None.
Returns
The text, empty unless the outcome is throw_outcome::std_exception.

Returns the text recorded when a std::exception was thrown.

Definition at line 1157 of file detail-inlines.h.

1159 {
1160 return what_;

References what_.

Referenced by callable_op().

Member Data Documentation

◆ outcome_

throw_outcome micro_os_plus::micro_test_plus::detail::callable_op::outcome_ { throw_outcome::none }
private

Copied from the callable_result by the constructor.

Definition at line 1461 of file detail.h.

Referenced by callable_op(), and outcome().

◆ value_

const bool micro_os_plus::micro_test_plus::detail::callable_op::value_ {}
private

Computed once, by the derived operator constructor, which invokes the callable.

Definition at line 1453 of file detail.h.

Referenced by callable_op(), and operator bool().

◆ what_

std::string micro_os_plus::micro_test_plus::detail::callable_op::what_ {}
private

Moved from the callable_result by the constructor; empty in the usual case, so nothing is allocated.

Definition at line 1471 of file detail.h.

Referenced by callable_op(), and what().


The documentation for this struct was generated from the following files: