|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::operator and (const Lhs_T &lhs, const Rhs_T &rhs) |
| | Logical && (and) operator. Matches only if at least one operand is of local type (derived from local op).
|
template<class T>
requires type_traits::is_op<T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::operator not (const T &t) |
| | Logical ! (not) operator. Matches only if the operand is of local type (derived from local op).
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::operator or (const Lhs_T &lhs, const Rhs_T &rhs) |
| | Logical || (or) operator. Matches only if at least one operand is of local type (derived from local op).
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::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.
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::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 op).
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::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 op).
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::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.
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::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 op).
|
template<class Lhs_T, class Rhs_T>
requires type_traits::any_op<Lhs_T, Rhs_T> |
| constexpr auto | micro_os_plus::micro_test_plus::operators::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 op).
|
These overloads enable expressive, type-safe test assertions. Operators such as ==, !=, <, >, <=, and >= are defined in 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 specialised µTest++ operators are used with typed operands, failed checks display both actual and expected values, greatly improving report clarity.
These operators are restricted to operands derived from the local detail::op type. For constant values, this is achieved with provided literals (for example, 1_i), whilst dynamic values can be wrapped with converters such as mt::to_i{expression}.
Logical operators (&&, ||, !) are also supported and provide enhanced functionality when used with typed operands, allowing complex test conditions to be composed naturally and readably.
- Examples
ts.test ("Operators", [] (auto& t) {
using namespace micro_test_plus::operators;
using namespace micro_test_plus::literals;
t.expect (compute_answer () == 42_i) << "answer is 42 (with literal)";
t.expect (mt::to_i {compute_answer ()} == 42) << "answer is 42 (with cast)";
t.expect (compute_answer () != 43_i) << "answer is not 43";
t.expect (compute_answer () < 43_i) << "answer is < 43";
t.expect (compute_answer () <= 43_i) << "answer is <= 43";
t.expect (compute_answer () > 41_i) << "answer is > 41";
t.expect (compute_answer () >= 42_i) << "answer is >= 42";
});
- Logical Operators
Logical operators provide enhanced reporting when used with typed operands, allowing complex test conditions to be composed naturally and readably.
- Example
ts.test ("Logical operators", [] (auto& t) {
using namespace micro_test_plus::operators;
using namespace micro_test_plus::literals;
t.expect (compute_answer () == 42_i && compute_float () == 42.0_f);
});