Skip to main content

The Logical Functions Reference

Functions used to compose logical expressions in tests. More...

Functions Index

constexpr auto_and (const Lhs_T &lhs, const Rhs_T &rhs)

Generic logical and operation. More...

constexpr auto_not (const Expr_T &expr)

Generic logical not operation. More...

constexpr auto_or (const Lhs_T &lhs, const Rhs_T &rhs)

Generic logical or operation. More...

Description

Functions used to compose logical expressions in tests.

The µTest++ framework provides logical functions for composing complex test expressions within a single statement. The functions mt::_and(), mt::_or(), and mt::_not() enable the combination of multiple conditions, allowing for expressive and concise test logic.

These function names are prefixed with an underscore because and, or, and not are reserved keywords in both C and C++. By using these logical functions, developers can clearly express compound conditions and improve the readability of their test cases.

Example
 mt::expect(mt::_and (mt::eq (compute_answer (), 42), mt::eq (compute_float
 (), 42.0)));

When the operands are function comparators, it is recommended to use the overloaded logical operators &&, ||, and ! provided within the micro_test_plus::operators namespace for even more natural expression of logical conditions.

Functions

_and()

template <class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::_and (const Lhs_T & lhs, const Rhs_T & rhs)
nodiscardconstexpr

Generic logical and operation.

Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
[in] lhsLeft hand side operand.
[in] rhsRight hand side operand.
Returns

An object that evaluates to true if both operand expressions are true.

The _and function template provides a generic logical conjunction for any expression types. It constructs a logical conjunction object that can be used within the µTest++ framework to assert that both given conditions are true. This function is typically used in test expectations and assertions to combine logical expressions or custom comparators.

The underscore in the function name is intentional to differentiate it from the standard logical and operator.

Definition at line 288 of file function-comparators-inlines.h.

_not()

template <class Expr_T>
auto micro_os_plus::micro_test_plus::_not (const Expr_T & expr)
nodiscardconstexpr

Generic logical not operation.

Template Parameters
Expr_TType of the operand.
Parameters
[in] exprLogical expression to be negated.
Returns

An object that evaluates to true if the operand is false.

The _not function template provides a generic logical negation for any expression type. It constructs a logical negator object that can be used within the µTest++ framework to assert that a given condition is false. This function is typically used in test expectations and assertions to invert logical expressions or custom comparators.

The underscore in the function name is intentional to differentiate it from the standard logical not operator.

Definition at line 270 of file function-comparators-inlines.h.

_or()

template <class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::_or (const Lhs_T & lhs, const Rhs_T & rhs)
nodiscardconstexpr

Generic logical or operation.

Template Parameters
Lhs_TType of the left hand side operand.
Rhs_TType of the right hand side operand.
Parameters
[in] lhsLeft hand side operand.
[in] rhsRight hand side operand.
Returns

An object that evaluates to true if at least one of the operand expressions is true.

The _or function template provides a generic logical disjunction for any expression types. It constructs a logical disjunction object that can be used within the µTest++ framework to assert that at least one of the given conditions is true. This function is typically used in test expectations and assertions to combine logical expressions or custom comparators.

The underscore in the function name is intentional to differentiate it from the standard logical or operator.

Definition at line 306 of file function-comparators-inlines.h.


Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.