The Assumptions Reference
Assumptions are conditions that must be satisfied for a test to proceed. More...
Functions Index
template < ... > | |
constexpr auto | assume (const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current()) |
Check a condition and, if false, abort test execution. More... | |
Description
Assumptions are conditions that must be satisfied for a test to proceed.
Assumptions represent essential preconditions that must hold true for a test case to execute meaningfully. If an assumption fails, the test is immediately terminated, as continuing would render the results invalid or misleading.
By clearly specifying assumptions, developers can ensure that tests are only run in appropriate contexts, improving the reliability and accuracy of test outcomes. This mechanism is particularly valuable for guarding against invalid input, incomplete initialisation, or unsupported environments.
Functions
assume()
| constexpr |
Check a condition and, if false, abort test execution.
- Template Parameters
-
Expr_T The type of the custom expression.
(SFINAE) Enabled only if Expr_T is derived from detail::op or is convertible to bool.
- 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 assume 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 188 of file micro-test-plus-inlines.h.
Generated via doxygen2docusaurus by Doxygen 1.14.0.