The Expectations Reference
Expectations are checks whose outcomes are reported. More...
Functions Index
template < ... > | |
constexpr auto | expect (const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current()) |
Evaluate a generic condition and report the results. More... | |
Description
Expectations are checks whose outcomes are reported.
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.
Functions
expect()
| constexpr |
Evaluate a generic condition and report the results.
- Template Parameters
Expr_T The type of the custom expression. (SFINAE) Enabled only if Expr_T
is derived fromdetail::op
or is convertible tobool
.
- Parameters
[in] expr Logical expression to evaluate. [in] sl Optional source location, defaulting to the current line.
- Returns
An output stream to write optional messages.
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.
- Example
Definition at line 155 of file micro-test-plus-inlines.h.
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.