micro-test-plus 6.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
function-comparators.h File Reference

C++ header file with declarations for the µTest++ function comparators. More...

Go to the source code of this file.

Namespaces

namespace  micro_os_plus
 The primary namespace for the µOS++ framework.
namespace  micro_os_plus::micro_test_plus
 Primary namespace for the µTest++ testing framework.

Functions

template<class First_T, class Second_T, class... Rest_T>
requires (extension::checkable<std::remove_cvref_t<First_T>> and extension::checkable<std::remove_cvref_t<Second_T>> and
(extension::checkable<std::remove_cvref_t<Rest_T>> and ...))
constexpr auto micro_os_plus::micro_test_plus::all_of (First_T &&first, Second_T &&second, Rest_T &&... rest)
 Generic logical and operation, for two or more operands.
template<class First_T, class Second_T, class... Rest_T>
requires (extension::checkable<std::remove_cvref_t<First_T>> and extension::checkable<std::remove_cvref_t<Second_T>> and
(extension::checkable<std::remove_cvref_t<Rest_T>> and ...))
constexpr auto micro_os_plus::micro_test_plus::any_of (First_T &&first, Second_T &&second, Rest_T &&... rest)
 Generic logical (inclusive) or operation, for two or more operands.
template<class Lhs_T, class Rhs_T, class Epsilon_T>
requires (extension::approx_operand<Lhs_T> and extension::approx_operand<Rhs_T> and extension::approx_operand<Epsilon_T>)
constexpr auto micro_os_plus::micro_test_plus::approx (Lhs_T &&lhs, Rhs_T &&rhs, Epsilon_T &&epsilon)
 Approximate equality comparator, with an explicit tolerance.
template<class Lhs_T, class Rhs_T>
requires detail::comparable_operands<detail::comparison::equal, Lhs_T, Rhs_T>
constexpr auto micro_os_plus::micro_test_plus::eq (Lhs_T &&lhs, Rhs_T &&rhs)
 Generic equality comparator.
template<class Lhs_T, class Rhs_T>
requires detail::comparable_operands<detail::comparison::greater_equal, Lhs_T, Rhs_T>
constexpr auto micro_os_plus::micro_test_plus::ge (Lhs_T &&lhs, Rhs_T &&rhs)
 Generic greater than or equal comparator.
template<class Lhs_T, class Rhs_T>
requires detail::comparable_operands<detail::comparison::greater, Lhs_T, Rhs_T>
constexpr auto micro_os_plus::micro_test_plus::gt (Lhs_T &&lhs, Rhs_T &&rhs)
 Generic greater than comparator.
template<class Lhs_T, class Rhs_T>
requires detail::comparable_operands<detail::comparison::less_equal, Lhs_T, Rhs_T>
constexpr auto micro_os_plus::micro_test_plus::le (Lhs_T &&lhs, Rhs_T &&rhs)
 Generic less than or equal comparator.
template<class Lhs_T, class Rhs_T>
requires detail::comparable_operands<detail::comparison::less, Lhs_T, Rhs_T>
constexpr auto micro_os_plus::micro_test_plus::lt (Lhs_T &&lhs, Rhs_T &&rhs)
 Generic less than comparator.
template<class Lhs_T, class Rhs_T>
requires detail::comparable_operands<detail::comparison::not_equal, Lhs_T, Rhs_T>
constexpr auto micro_os_plus::micro_test_plus::ne (Lhs_T &&lhs, Rhs_T &&rhs)
 Generic non-equality comparator.
template<class Expr_T>
requires extension::checkable<std::remove_cvref_t<Expr_T>>
constexpr auto micro_os_plus::micro_test_plus::negate (Expr_T &&expr)
 Generic logical not operation.

Detailed Description

This header provides the declarations for the function comparator templates and logical operators used within the µTest++ framework. It defines the interfaces for the generic comparison functions, including equality, non-equality, greater than, less than, greater than or equal, and less than or equal, and the approximate comparison with an explicit tolerance (approx). Additionally, it declares logical combinators such as conjunction (all_of), disjunction (any_of), and negation (negate); their deprecated v5.0.1 names are declared in deprecated.h.

The C strings (the arrays, including the string literals, and the pointers of the character types) are compared by content, and so are the other arrays (e.g. byte buffers), element by element; the other pointers are compared by address. The temporaries are moved into the returned expressions, and the named operands are copied, so an expression can be returned from the function that builds it, and kept after the operands are destroyed, except for the arrays and the characters of the C strings, which are referred to and must outlive the expression. The copy is made for every check, passing or failing, so a large container or string costs an allocation; compare a std::string_view of a string instead, when the cost matters. The logical combinators have descriptive names, since and, or, and not are alternative tokens and cannot be used as identifiers.

All definitions reside within the micro_os_plus::micro_test_plus namespace.

This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.

Definition in file function-comparators.h.