|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Functions used to compose logical expressions in tests. More...
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 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. | |
Three functions combine the conditions of a check, and report the values of all their operands when the check fails:
all_of() and any_of() take two or more operands; a failed check shows them as one group, for example (1 == 1 and 1 == 1 and 1 == 3).
The functions have names, rather than the &&, ||, and ! operators, because the built-in operators would return a plain bool, which loses the values of the operands.
The overloaded logical operators of the mt::operators namespace are deprecated since 6.0.0, in favour of these functions.
|
nodiscardconstexpr |
| First_T | Type of the first operand. |
| Second_T | Type of the second operand. |
| Rest_T | Types of the other operands, if any. |
| first | First operand. |
| second | Second operand. |
| rest | The other operands, if any. |
The all_of function template provides a generic logical conjunction for any expression types. It constructs a detail::and_op logical conjunction object, which evaluates to true if all the operands are true. For more than two operands, the objects are nested from the left, (a and b) and c, and the expression formatter writes them as a single chain, (a and b and c).
All the operands are evaluated before the check, so, unlike the standard algorithm of the same name, the function does not stop at the first operand that is false.
The name is the same as that of std::all_of: after a using namespace std, an unqualified call with three or more operands of the same type selects the standard algorithm, so the function must be called as mt::all_of().
Definition at line 360 of file function-comparators-inlines.h.
References all_of().
|
nodiscardconstexpr |
| First_T | Type of the first operand. |
| Second_T | Type of the second operand. |
| Rest_T | Types of the other operands, if any. |
| first | First operand. |
| second | Second operand. |
| rest | The other operands, if any. |
The any_of function template provides a generic logical disjunction for any expression types. It constructs a detail::or_op logical disjunction object, which evaluates to true if at least one of the operands is true; the disjunction is inclusive, so the result is also true when all the conditions are true. For more than two operands, the objects are nested from the left, and the expression formatter writes them as a single chain, (a or b or c).
All the operands are evaluated before the check, so the function does not stop at the first operand that is true; and, as for all_of(), it must be called as mt::any_of() after a using namespace std.
Definition at line 395 of file function-comparators-inlines.h.
References any_of().
|
nodiscardconstexpr |
| Expr_T | Type of the operand. |
| expr | Logical expression to be negated. |
The negate function template provides a generic logical negation for any expression type. It constructs a detail::not_op logical negator object, which evaluates to true if the operand is false; the template argument is named, since the class template argument deduction would copy an operand that is itself a not_op, instead of negating it.
It is the function form of the ! operator from the micro_test_plus::operators namespace.
Definition at line 330 of file function-comparators-inlines.h.
References negate().