|
micro-test-plus 4.1.0
µTest++ Testing Framework
|
Assumptions are conditions that must be satisfied for a test to proceed. More...
Functions | |
| template<class Expr_T> requires type_traits::checkable<Expr_T> | |
| auto | micro_os_plus::micro_test_plus::subtest::assume (const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current()) |
| Check a condition and, if false, abort test execution. | |
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.
| auto micro_os_plus::micro_test_plus::subtest::assume | ( | const Expr_T & | expr, |
| const reflection::source_location & | sl = reflection::source_location::current () ) |
| Expr_T | The type of the custom expression. |
| [in] | expr | Logical expression to evaluate. |
| [in] | sl | Optional source location, defaulting to the current line. |
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.
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 operator=().