The Operators Reference
Overloaded operators for expressive test comparisons. More...
Functions Index
constexpr auto | operator and (const Lhs_T &lhs, const Rhs_T &rhs) |
Logical | |
constexpr auto | operator not (const T &t) |
Logical | |
constexpr auto | operator or (const Lhs_T &lhs, const Rhs_T &rhs) |
Logical | |
constexpr auto | operator!= (const Lhs_T &lhs, const Rhs_T &rhs) |
Non-equality operator for custom types. Matches only if at least one operand is of local type. More... | |
constexpr auto | operator< (const Lhs_T &lhs, const Rhs_T &rhs) |
Less than operator. Matches only if at least one operand is of local type (derived from local | |
constexpr auto | operator<= (const Lhs_T &lhs, const Rhs_T &rhs) |
Less than or equal operator. Matches only if at least one operand is of local type (derived from local | |
constexpr auto | operator== (const Lhs_T &lhs, const Rhs_T &rhs) |
Equality operator for custom types. Matches only if at least one operand is of local type. More... | |
constexpr auto | operator> (const Lhs_T &lhs, const Rhs_T &rhs) |
Greater than operator. Matches only if at least one operand is of local type (derived from local | |
constexpr auto | operator>= (const Lhs_T &lhs, const Rhs_T &rhs) |
Greater than or equal operator. Matches only if at least one operand is of local type (derived from local | |
Description
The µTest++ framework provides overloaded comparison and logical operators to enable expressive and type-safe test assertions. These operators—such as ==
, !=
, <
, >
, <=
, and >=
—are defined within the dedicated micro_test_plus::operators
namespace to avoid conflicts with application-defined operators.
For standard values, the default operators are used, ensuring correct comparisons. However, when using the specialised µTest++ operators with typed operands, failed checks will display both the actual and expected values, greatly improving the clarity of test reports.
These operators are restricted to operands derived from the local detail::op
type. For constant values, this is achieved using provided literals (e.g., 1_i
), while dynamic values can be wrapped using casts such as mt::to_i{expression}
.
Logical operators (&&
, ||
, !
) are also supported and provide enhanced functionality when used with typed operands, allowing for the composition of complex test conditions in a natural and readable manner.
- Examples
Logical operators
Logical operators may be used in the same way as standard operators, with enhanced reporting available when used with typed operands.
- Example
Functions
operator and()
| nodiscardconstexpr |
Logical &&
(and) operator. Matches only if at least one operand is of local type (derived from local op
).
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A logical conjunction object that evaluates to true if both operands are true.
This overload of the logical &&
(and) operator enables conjunction between two operands, where at least one is a local type derived from the local op
base. It constructs a logical conjunction object that can be used within the µTest++ framework to assert that both operands evaluate to true. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 431 of file operators.h.
operator not()
| nodiscardconstexpr |
Logical !
(not) operator. Matches only if the operand is of local type (derived from local op
).
- Template Parameters
T Type of the operand, constrained to types derived from the local op
base.
- Parameters
[in] t Operand to be logically negated.
- Returns
A logical negator object that evaluates to true if the operand is false.
This overload of the logical !
(not) operator enables logical negation of an operand, provided it is a local type derived from the local op
base. It constructs a logical negator object that can be used within the µTest++ framework to assert that a given condition is false. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 491 of file operators.h.
operator or()
| nodiscardconstexpr |
Logical ||
(or) operator. Matches only if at least one operand is of local type (derived from local op
).
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A logical disjunction object that evaluates to true if at least one operand is true.
This overload of the logical ||
(or) operator enables disjunction between two operands, where at least one is a local type derived from the local op
base. It constructs a logical disjunction object that can be used within the µTest++ framework to assert that at least one operand evaluates to true. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 463 of file operators.h.
operator!=()
| nodiscardconstexpr |
Non-equality operator for custom types. Matches only if at least one operand is of local type.
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A comparator object that evaluates to true if the operands are not equal.
This overload of the non-equality operator enables comparison between two operands, where at least one is a local type derived from the local op
base. It constructs a comparator object that can be used within the µTest++ framework to assert that the operands are not equal. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 269 of file operators.h.
operator<()
| nodiscardconstexpr |
Less than operator. Matches only if at least one operand is of local type (derived from local op
).
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A comparator object that evaluates to true if the left hand side operand is less than the right hand side operand.
This overload of the less than operator enables comparison between two operands, where at least one is a local type derived from the local op
base. It constructs a comparator object that can be used within the µTest++ framework to assert that the left hand side operand is less than the right hand side operand. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 365 of file operators.h.
operator<=()
| nodiscardconstexpr |
Less than or equal operator. Matches only if at least one operand is of local type (derived from local op
).
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A comparator object that evaluates to true if the left hand side operand is less than or equal to the right hand side operand.
This overload of the less than or equal operator enables comparison between two operands, where at least one is a local type derived from the local op
base. It constructs a comparator object that can be used within the µTest++ framework to assert that the left hand side operand is less than or equal to the right hand side operand. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 398 of file operators.h.
operator==()
| nodiscardconstexpr |
Equality operator for custom types. Matches only if at least one operand is of local type.
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A comparator object that evaluates to true if the operands are equal.
This overload of the equality operator enables comparison between two operands, where at least one is a local type derived from the local op
base. It constructs a comparator object that can be used within the µTest++ framework to assert that the operands are equal. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 237 of file operators.h.
operator>()
| nodiscardconstexpr |
Greater than operator. Matches only if at least one operand is of local type (derived from local op
).
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A comparator object that evaluates to true if the left hand side operand is greater than the right hand side operand.
This overload of the greater than operator enables comparison between two operands, where at least one is a local type derived from the local op
base. It constructs a comparator object that can be used within the µTest++ framework to assert that the left hand side operand is greater than the right hand side operand. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 301 of file operators.h.
operator>=()
| nodiscardconstexpr |
Greater than or equal operator. Matches only if at least one operand is of local type (derived from local op
).
- Template Parameters
Lhs_T Type of the left hand side operand. Rhs_T Type of the right hand side operand.
- Parameters
[in] lhs Left hand side operand. [in] rhs Right hand side operand.
- Returns
A comparator object that evaluates to true if the left hand side operand is greater than or equal to the right hand side operand.
This overload of the greater than or equal operator enables comparison between two operands, where at least one is a local type derived from the local op
base. It constructs a comparator object that can be used within the µTest++ framework to assert that the left hand side operand is greater than or equal to the right hand side operand. This operator is intended for use with the framework's strongly-typed constants, wrappers, or other custom types, ensuring type-safe and expressive test assertions.
Definition at line 334 of file operators.h.
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.