micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches

Deprecated overloaded operators for test comparisons. More...

Functions

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator and (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated logical && (and) operator.
template<class T>
requires extension::is_op<std::remove_cvref_t<T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator not (T &&t)
 Deprecated logical ! (not) operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator or (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated logical || (or) operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator!= (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated non-equality operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator< (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated less than operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator<= (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated less than or equal operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator== (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated equality operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator> (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated greater than operator.
template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
constexpr auto micro_os_plus::micro_test_plus::operators::operator>= (Lhs_T &&lhs, Rhs_T &&rhs)
 Deprecated greater than or equal operator.

Detailed Description

The mt::operators namespace defines the comparison operators ==, !=, <, >, <=, and >=, and the logical operators and, or, and not, for the framework expression types. After using namespace mt::operators, a check such as t.expect (mt::to_i{ compute_answer () } == 42_i) reports the values of its operands, as the function comparators do.

Deprecated
The operators are deprecated since 6.0.0, in favour of the function comparators mt::eq(), mt::ne(), mt::lt(), mt::le(), mt::gt(), and mt::ge(), and of the logical functions mt::all_of(), mt::any_of(), and mt::negate(), which check and report the plain values, without literal suffixes or wrappers.
Limitations
  • The operators apply only when at least one operand is a framework expression type (see extension::is_op): a deprecated literal, such as 1_i, or a deprecated wrapper, such as mt::to_i{ value }. When neither operand is, the standard operator is selected; it returns a plain bool, so a failed check cannot show the operands.
  • The overloaded and and or operators evaluate both operands before the check, so they do not short-circuit like the built-in ones.
Replacement
ts.test ("Comparators", [] (auto& t) {
t.expect (mt::eq (compute_answer (), 42)) << "answer is 42";
t.expect (mt::ne (compute_answer (), 43)) << "answer is not 43";
t.expect (mt::lt (compute_answer (), 43)) << "answer is < 43";
t.expect (mt::le (compute_answer (), 43)) << "answer is <= 43";
t.expect (mt::gt (compute_answer (), 41)) << "answer is > 41";
t.expect (mt::ge (compute_answer (), 42)) << "answer is >= 42";
t.expect (mt::all_of (mt::eq (compute_answer (), 42),
mt::eq (compute_float (), 42.0f)));
});
Primary namespace for the µTest++ testing framework.

Function Documentation

◆ operator and()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator and ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
A logical conjunction object that evaluates to true if both operands are true.
Deprecated
use all_of() (since 6.0.0)

Constructs an and_op logical conjunction object from the two operands and returns it. The object evaluates to true if both operands are true. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 854 of file deprecated-inlines.h.

855 {
856 return detail::and_op{ std::forward<Lhs_T> (lhs),
857 std::forward<Rhs_T> (rhs) };
858 }
Logical AND comparator struct template.
Definition detail.h:1083

◆ operator not()

template<class T>
requires extension::is_op<std::remove_cvref_t<T>>
auto micro_os_plus::micro_test_plus::operators::operator not ( T && t)
nodiscardconstexpr
Template Parameters
TType of the operand, constrained to the framework expression types.
Parameters
tOperand to be logically negated.
Returns
A logical negator object that evaluates to true if the operand is false.
Deprecated
use negate() (since 6.0.0)

Constructs a not_op logical negator object from the operand and returns it. The object evaluates to true if the operand is false. The operand must be a framework expression type (see extension::is_op).

Definition at line 886 of file deprecated-inlines.h.

887 {
888 // Not `not_op{ t }`, which would copy an operand that is itself
889 // a `not_op`, instead of negating it.
890 return detail::not_op<detail::stored_operand_t<T>>{ std::forward<T> (
891 t) };
892 }
Logical NOT comparator struct template.
Definition detail.h:1195

◆ operator or()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator or ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
A logical disjunction object that evaluates to true if at least one operand is true.
Deprecated
use any_of() (since 6.0.0)

Constructs an or_op logical disjunction object from the two operands and returns it. The object evaluates to true if at least one operand is true. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 871 of file deprecated-inlines.h.

872 {
873 return detail::or_op{ std::forward<Lhs_T> (lhs),
874 std::forward<Rhs_T> (rhs) };
875 }
Logical OR comparator struct template.
Definition detail.h:1138

◆ operator!=()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator!= ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
A comparator object that evaluates to true if the operands are not equal.
Deprecated
use ne() (since 6.0.0)

Constructs a comparator object, with the not_equal_to tag, from the two operands and returns it. The comparator evaluates to true if the operands are not equal. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 765 of file deprecated-inlines.h.

766 {
767 return detail::compare_op{ std::forward<Lhs_T> (lhs),
768 std::forward<Rhs_T> (rhs),
770 }
Relational comparator struct template.
Definition detail.h:887
Non-equality tag for compare_op.
Definition detail.h:501

◆ operator<()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator< ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight 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.
Deprecated
use lt() (since 6.0.0)

Constructs a comparator object, with the less tag, from the two operands and returns it. The comparator evaluates to true if lhs is less than rhs. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 818 of file deprecated-inlines.h.

820 {
821 return detail::compare_op{ std::forward<Lhs_T> (lhs),
822 std::forward<Rhs_T> (rhs), detail::less{} };
823 }
Less than tag for compare_op.
Definition detail.h:678

◆ operator<=()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator<= ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight 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.
Deprecated
use le() (since 6.0.0)

Constructs a comparator object, with the less_equal tag, from the two operands and returns it. The comparator evaluates to true if lhs is less than or equal to rhs. At least one operand must be a framework type (see extension::is_op).

Definition at line 835 of file deprecated-inlines.h.

837 {
838 return detail::compare_op{ std::forward<Lhs_T> (lhs),
839 std::forward<Rhs_T> (rhs),
841 }
Less than or equal tag for compare_op.
Definition detail.h:737

◆ operator==()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator== ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
A comparator object that evaluates to true if the operands are equal.
Deprecated
use eq() (since 6.0.0)

Constructs a comparator object, with the equal_to tag, from the two operands and returns it. The comparator evaluates to true if the operands are equal. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 747 of file deprecated-inlines.h.

748 {
749 return detail::compare_op{ std::forward<Lhs_T> (lhs),
750 std::forward<Rhs_T> (rhs),
752 }

◆ operator>()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator> ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight 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.
Deprecated
use gt() (since 6.0.0)

Constructs a comparator object, with the greater tag, from the two operands and returns it. The comparator evaluates to true if lhs is greater than rhs. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 783 of file deprecated-inlines.h.

784 {
785 return detail::compare_op{ std::forward<Lhs_T> (lhs),
786 std::forward<Rhs_T> (rhs),
787 detail::greater{} };
788 }
Greater than tag for compare_op.
Definition detail.h:560

◆ operator>=()

template<class Lhs_T, class Rhs_T>
requires extension::any_op<std::remove_cvref_t<Lhs_T>, std::remove_cvref_t<Rhs_T>>
auto micro_os_plus::micro_test_plus::operators::operator>= ( Lhs_T && lhs,
Rhs_T && rhs )
nodiscardconstexpr
Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
lhsLeft hand side operand.
rhsRight 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.
Deprecated
use ge() (since 6.0.0)

Constructs a comparator object, with the greater_equal tag, from the two operands and returns it. The comparator evaluates to true if lhs is greater than or equal to rhs. At least one operand must be a framework expression type (see extension::is_op).

Definition at line 801 of file deprecated-inlines.h.

802 {
803 return detail::compare_op{ std::forward<Lhs_T> (lhs),
804 std::forward<Rhs_T> (rhs),
806 }
Greater than or equal tag for compare_op.
Definition detail.h:619