|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Approximate comparator 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 L, class R, class E> | |
| constexpr | approx_op (L &&lhs, R &&rhs, E &&epsilon) |
| Constructs an approximate comparator for the given operands. | |
| constexpr decltype(auto) | epsilon (void) const |
| Retrieves the tolerance. | |
| constexpr decltype(auto) | lhs (void) const |
| Retrieves the left-hand operand. | |
| constexpr | operator bool () const |
| Conversion operator to boolean. | |
| constexpr decltype(auto) | rhs (void) const |
| Retrieves the right-hand operand. | |
Private Attributes | |
| Epsilon_T | epsilon_ |
| The stored tolerance. | |
| Lhs_T | lhs_ |
| Stores the left-hand operand. | |
| Rhs_T | rhs_ |
| Stores the right-hand operand. | |
| const bool | value_ {} |
| Stores the result of the comparison. | |
Derived from binary_op, this struct compares two numbers with an explicit tolerance, given as a third operand: the comparison succeeds if the distance between the numbers is at most the tolerance (see detail::differ_by_at_most()). The result is computed at construction time. It is created by the approx (lhs, rhs, epsilon) function comparator, and reported as lhs ~ (rhs +/- epsilon).
The operands may be framework value wrappers or numeric literals, which are unwrapped; their own tolerance, if any, is not used.
| Lhs_T | The type of the stored left-hand operand, either the operand type, or a const reference to it (see stored_operand_t). |
| Rhs_T | The type of the stored right-hand operand, either the operand type, or a const reference to it. |
| Epsilon_T | The type of the stored tolerance, either the operand type, or a const reference to it. |
|
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 arguments, before they are forwarded to the members.
| L | The type of the left-hand operand argument. |
| R | The type of the right-hand operand argument. |
| E | The type of the tolerance argument. |
| lhs | The left-hand operand. |
| rhs | The right-hand operand. |
| epsilon | The tolerance. |
The result is computed from the unwrapped arguments, with detail::differ_by_at_most(), before the operands are forwarded to the base and the tolerance to its member.
Definition at line 1008 of file detail-inlines.h.
References micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::binary_op(), micro_os_plus::micro_test_plus::detail::differ_by_at_most(), epsilon(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::lhs(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs(), and micro_os_plus::micro_test_plus::detail::unwrap().
|
nodiscardconstexpr |
The tolerance is unwrapped with detail::unwrap(), as the operands are.
Returns the stored tolerance, unwrapped with detail::unwrap().
Definition at line 1026 of file detail-inlines.h.
References epsilon(), epsilon_, and micro_os_plus::micro_test_plus::detail::unwrap().
Referenced by approx_op(), and epsilon().
|
nodiscardconstexprinherited |
The operand is unwrapped with detail::unwrap() and returned by reference, so that formatting it does not copy it.
Returns the value of the left-hand operand, unwrapped by detail::unwrap() if it is a framework wrapper type; the stored operand is not copied.
Definition at line 181 of file detail-inlines.h.
References lhs(), lhs_, and micro_os_plus::micro_test_plus::detail::unwrap().
Referenced by micro_os_plus::micro_test_plus::detail::and_op< Lhs_T, Rhs_T >::and_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), binary_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::or_op< Lhs_T, Rhs_T >::or_op(), and lhs().
|
nodiscardconstexprinherited |
Returns the pre-computed boolean result stored by the derived comparator's constructor.
Definition at line 167 of file detail-inlines.h.
References binary_op(), and value_.
|
nodiscardconstexprinherited |
The operand is unwrapped with detail::unwrap() and returned by reference, so that formatting it does not copy it.
Returns the value of the right-hand operand, unwrapped by detail::unwrap() if it is a framework wrapper type; the stored operand is not copied.
Definition at line 194 of file detail-inlines.h.
References rhs(), rhs_, and micro_os_plus::micro_test_plus::detail::unwrap().
Referenced by micro_os_plus::micro_test_plus::detail::and_op< Lhs_T, Rhs_T >::and_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), binary_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::or_op< Lhs_T, Rhs_T >::or_op(), and rhs().
|
private |
Stored as the operands are (see stored_operand_t), only to be reported; the result was already computed by the constructor.
Definition at line 1044 of file detail.h.
Referenced by epsilon().
|
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 410 of file detail.h.
Referenced by binary_op(), and lhs().
|
privateinherited |
Stored as the left-hand operand is.
Definition at line 418 of file detail.h.
Referenced by binary_op(), and rhs().
|
privateinherited |
Computed once, by the derived comparator constructor.
Definition at line 426 of file detail.h.
Referenced by binary_op(), and operator bool().