![]() |
micro-test-plus 3.2.2
µTest++ Testing Framework
|
Expectations are checks whose outcomes are reported. More...
Functions | |
template<class Expr_T, type_traits::requires_t< type_traits::is_op_v< Expr_T > or type_traits::is_convertible_v< Expr_T, bool > > = 0> | |
constexpr auto | micro_os_plus::micro_test_plus::expect (const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current()) |
Evaluate a generic condition and report the results. |
Expectations are conditions that are verified during test execution, with their outcomes—whether passing or failing—being explicitly reported in the test results. Unlike assumptions, a failed expectation does not cause the test to terminate; instead, execution continues, allowing multiple conditions to be checked within a single test case.
This approach enables comprehensive validation of code behaviour, as all relevant expectations can be evaluated and reported in one run. By using expectations, developers gain detailed insight into which aspects of the code meet requirements and which do not, supporting thorough and efficient testing practices.
|
constexpr |
Expr_T | The type of the custom expression. |
(SFINAE) | Enabled only if Expr_T is derived from detail::op or is convertible to bool. |
[in] | expr | Logical expression to evaluate. |
[in] | sl | Optional source location, defaulting to the current line. |
The expect function template evaluates a logical condition or custom expression and reports the result within the µTest++ framework. It is designed to provide detailed diagnostics for test failures, including the actual and expected values, when using the provided comparators (eq(), ne(), lt(), le(), gt(), ge()) or custom operators.
The function template can be used with any expression that evaluates to a boolean or with custom comparators/operators derived from the local detail::op type. For complex checks performed outside the expect() logical expression (such as within if or try/catch statements), the result can be reported by calling expect(true) or expect(false).
The function returns an output stream, allowing optional messages to be appended to the test report.
Definition at line 155 of file micro-test-plus-inlines.h.