Assumptions
Assumptions are conditions that must be satisfied for a test to proceed. More...
Functions Index
template <class Expr_T> | |
| 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.
When a required precondition does not hold, the test cannot execute meaningfully. If an assumption fails, the test is terminated immediately, as continuing would render the results invalid or misleading.
By explicitly defining assumptions, developers ensure that tests run only in appropriate contexts, improving the reliability and accuracy of outcomes. This mechanism is particularly valuable for guarding against invalid input, incomplete initialisation, and unsupported environments.
Functions
assume()
|
Check a condition and, if false, abort test execution.
- Template Parameters
-
Expr_T The type of the custom expression.
- Constraints
Enabled only if Expr_T is derived from detail::op or is convertible to bool (enforced via a C++20 requires clause).
- 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.
Constructs and returns a deferred_reporter<Expr_T> with abort = true. The reporter evaluates the condition, records a pass or fail when it is destroyed, and aborts execution if the condition is false.
Declaration at line 653 of file test.h, definition at line 345 of file test-inlines.h.
References micro_os_plus::micro_test_plus::reporter::expression and micro_os_plus::micro_test_plus::detail::runnable< subtest >::reporter.
Referenced by micro_os_plus::micro_test_plus::subtest::operator=.
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.