|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Unary predicate struct template. More...
#include "micro-os-plus/micro-test-plus.h"
Public Types | |
| using | op_type = op |
| Marker identifying the framework expression types. | |
Public Member Functions | |
| template<class U> requires extension::predicate_tag<Predicate_T, unwrapped_t<U>> | |
| constexpr | predicate_op (U &&t, Predicate_T) |
| Constructs a predicate for the given operand. | |
| constexpr decltype(auto) | operand (void) const |
| Retrieves the wrapped operand expression. | |
| constexpr | operator bool () const |
| Conversion operator to boolean. | |
Private Attributes | |
| T | t_ |
| Stores the operand. | |
| const bool | value_ {} |
| Stores the result of the operation. | |
Derived from unary_op, this struct checks a property of a single operand, using the predicate defined by the tag Predicate_T, and reports the symbol of the tag followed by the operand upon failure, as not_op reports not.
It is public, as extension::predicate_op, so that the applications can define their own predicates with their own tags. A tag is an empty struct with:
The tag is passed as an empty constructor argument, so that both template arguments are deduced, for example predicate_op{ value, even{} }.
A temporary is moved into the predicate, and a named operand is copied (see stored_operand_t), so a predicate built in a function from its const& parameter can be returned from it.
| T | The type of the stored operand, either the operand type, or a const reference to it. |
| Predicate_T | The tag that defines the predicate. It is stateless, with a static symbol and a static apply(); a predicate that needs a parameter is a comparison of two operands (see compare_op). |
|
inherited |
Detected by the extension::is_op concept, and inherited by all types derived from op.
Definition at line 128 of file extension.h.
|
constexpr |
The result is computed from the argument, before it is forwarded to the base. The tag argument is used only to deduce Predicate_T.
| U | The type of the operand argument. |
| t | The operand. |
Applies the predicate of the tag to the unwrapped operand, and passes the boolean result, with the operand prepared by as_operand(), to the unary_op base class constructor.
Definition at line 1093 of file detail-inlines.h.
|
nodiscardconstexprinherited |
The operand is unwrapped with detail::unwrap() and returned by reference, so that formatting it does not copy it.
Returns the operand, unwrapped by detail::unwrap() if it is a framework wrapper type; the stored operand is not copied.
Definition at line 141 of file detail-inlines.h.
References operand(), t_, and micro_os_plus::micro_test_plus::detail::unwrap().
Referenced by operand().
|
nodiscardconstexprinherited |
Returns the pre-computed boolean result stored by the derived comparator's constructor.
Definition at line 128 of file detail-inlines.h.
References unary_op(), and value_.
|
privateinherited |
A value, moved from a temporary or copied from a named operand, or, for a named operand that cannot be copied, a const reference to it (see stored_operand_t). It is not const, so that a temporary expression can be moved into an enclosing one.
Definition at line 309 of file detail.h.
Referenced by unary_op(), and operand().
|
privateinherited |
Computed once, by the derived comparator constructor.
Definition at line 317 of file detail.h.
Referenced by unary_op(), and operator bool().