micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::operators Namespace Reference

Custom operator overloads for expressive and type-safe test assertions. More...

Functions

template<class Lhs_T, class Rhs_T, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
constexpr auto 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, type_traits::requires_t< type_traits::is_op_v< T > > = 0>
constexpr auto 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, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
constexpr auto 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, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
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.
constexpr auto operator!= (std::string_view lhs, std::string_view rhs)
 Non-equality operator for string_view objects.
template<class T, type_traits::requires_t< type_traits::is_container_v< T > > = 0>
constexpr auto operator!= (T &&lhs, T &&rhs)
 Non-equality operator for containers.
template<class Lhs_T, class Rhs_T, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
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 op).
template<class Lhs_T, class Rhs_T, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
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 op).
template<class Lhs_T, class Rhs_T, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
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.
constexpr auto operator== (std::string_view lhs, std::string_view rhs)
 Equality operator for string_view objects.
template<class T, type_traits::requires_t< type_traits::is_container_v< T > > = 0>
constexpr auto operator== (T &&lhs, T &&rhs)
 Equality operator for containers.
template<class Lhs_T, class Rhs_T, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
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 op).
template<class Lhs_T, class Rhs_T, type_traits::requires_t< type_traits::is_op_v< Lhs_T > or type_traits::is_op_v< Rhs_T > > = 0>
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 op).

Detailed Description

The micro_os_plus::micro_test_plus::operators namespace provides a comprehensive set of custom operator overloads designed to enable expressive, concise, and type-safe test assertions within the µTest++ framework.

This namespace includes equality, inequality, relational, and logical operators tailored for use with the framework’s custom types, containers, and string views. These operators facilitate the creation of clear and readable test expressions, supporting both strongly-typed constants (via user-defined literals) and dynamic values (via wrappers).

Warning
Please be aware that these operators may conflict with other operators defined within the application under test.

To minimise conflicts with application-defined operators, these overloads are enabled only for specific types recognised by the framework, such as those derived from the local op base type or identified as containers or string views. Constants typically require a literal suffix (e.g., 1_i), while dynamic values should be wrapped using the provided casting utilities (e.g., mt::to_i{...}).

All definitions within this namespace are implemented in the include/micro-os-plus/micro-test-plus folder, ensuring a modular and maintainable codebase.