Skip to main content

Expectations

Expectations are checks whose outcomes are counted and reported. More...

Functions Index

template <class Expr_T>
autoexpect (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 counted and reported.

During test execution, each condition outcome, whether passing or failing, is explicitly reported in test results. Unlike assumptions, a failed expectation does not terminate the test; execution continues, allowing multiple conditions to be checked within a single test case.

This approach enables comprehensive validation of code behaviour, because all relevant expectations can be evaluated and reported in one run. Using expectations provides detailed insight into which aspects of the code meet requirements and which do not, supporting thorough and efficient testing.

Functions

expect()

template <class Expr_T>
auto micro_os_plus::micro_test_plus::subtest::expect (const Expr_T & expr, const reflection::source_location & sl=reflection::source_location::current())

Evaluate a generic condition and report the results.

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 = false. The reporter evaluates the condition and records a pass or fail when it is destroyed at the end of the expression statement.

Declaration at line 633 of file test.h, definition at line 330 of file test-inlines.h.

330 subtest::expect (const Expr_T& expr, const reflection::source_location& sl)
331 {
332 return detail::deferred_reporter{ expr, false, sl, *this,
333 reporter ().expression () };
334 }

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.