Skip to main content

The deferred_reporter Class Template Reference

Deferred reporter class template for a specific expression. More...

Declaration

template <class Expr_T> class micro_os_plus::micro_test_plus::detail::deferred_reporter<Expr_T> { ... }

Included Headers

Base class

classdeferred_reporter_base

Base class for a deferred reporter that collects messages into a string. More...

Public Constructors Index

template <class Expr_T>
constexprdeferred_reporter (const Expr_T &expr, bool abort, const reflection::source_location &location)

Constructs a deferred reporter for a specific expression. More...

Public Destructor Index

template <class Expr_T>
~deferred_reporter ()

Destructor for the deferred reporter. More...

Public Operators Index

template <class T>
auto &operator<< (const T &msg)

Appends a message to the reporter. More...

Public Member Functions Index

template <class Expr_T>
constexpr boolvalue () const

Retrieves the result value. More...

Protected Member Attributes Index

template <class Expr_T>
boolabort_ = false

Indicates whether the reporting should abort further processing. More...

template <class Expr_T>
const Expr_Texpr_ {}

Stores the expression under evaluation. More...

template <class Expr_T>
const reflection::source_locationlocation_ {}

Stores the source location associated with the report. More...

template <class Expr_T>
std::stringmessage_ {}

String to collect the expectation message passed via operator<<(). More...

template <class Expr_T>
boolvalue_ {}

Stores the result value of the report. More...

Description

Deferred reporter class template for a specific expression.

Template Parameters
Expr_T

The type of the expression being reported.

The deferred_reporter class template extends deferred_reporter_base to provide deferred reporting functionality for a specific test expression within the framework.

This class template is responsible for capturing the expression under evaluation, the abort status, and the source location. It is intended exclusively for internal use and is implemented in the include/micro-os-plus/micro-test-plus folder to ensure a structured and modular codebase.

Definition at line 1836 of file detail.h.

Public Constructors

deferred_reporter()

template <class Expr_T>
micro_os_plus::micro_test_plus::detail::deferred_reporter< Expr_T >::deferred_reporter (const Expr_T & expr, bool abort, const reflection::source_location & location)
explicit constexpr

Constructs a deferred reporter for a specific expression.

Parameters
expr

The expression under evaluation.

abort

Indicates whether reporting should abort further processing.

location

The source location relevant to the report.

Initialises the reporter with the given expression, abort status, and source location.

This constructor initialises a deferred reporter for a specific expression, capturing the evaluation result, abort status, and source location.

The expression is evaluated and its boolean result is passed to the base class. The abort flag determines whether further test execution should be halted if the expectation fails. The source location provides contextual information for reporting purposes.

Declaration at line 1851 of file detail.h, definition at line 117 of file details-inlines.h.

118 const Expr_T& expr, bool abort,
119 const reflection::source_location& location)
120 : deferred_reporter_base{ static_cast<bool> (expr), location },
121 expr_{ expr }
122 {
123#if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
124 printf ("%s\n", __PRETTY_FUNCTION__);
125#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
126 abort_ = abort;
127 }

References micro_os_plus::micro_test_plus::detail::deferred_reporter_base::deferred_reporter_base, micro_os_plus::micro_test_plus::detail::deferred_reporter_base::abort_ and micro_os_plus::micro_test_plus::detail::deferred_reporter< Expr_T >::expr_.

Public Destructor

~deferred_reporter()

template <class Expr_T>
micro_os_plus::micro_test_plus::detail::deferred_reporter< Expr_T >::~deferred_reporter ()

Destructor for the deferred reporter.

The destructor finalises the deferred reporting process for a test expression. If the evaluated expression is true, the reporter records a successful outcome along with any accumulated message. If the expression is false, the reporter records a failure, including the abort status, message, and source location for comprehensive reporting.

This mechanism ensures that all relevant information about the test outcome is captured and reported accurately when the deferred reporter goes out of scope.

Declaration at line 1858 of file detail.h, definition at line 142 of file details-inlines.h.

143 {
144 if (value_)
145 {
146 reporter.pass (expr_, message_);
147 }
148 else
149 {
151 }
152 }

References micro_os_plus::micro_test_plus::detail::deferred_reporter_base::abort_, micro_os_plus::micro_test_plus::detail::deferred_reporter< Expr_T >::expr_, micro_os_plus::micro_test_plus::detail::deferred_reporter_base::location_, micro_os_plus::micro_test_plus::detail::deferred_reporter_base::message_, micro_os_plus::micro_test_plus::reporter and micro_os_plus::micro_test_plus::detail::deferred_reporter_base::value_.

Public Operators

operator<<()

template <class T>
auto & micro_os_plus::micro_test_plus::detail::deferred_reporter_base::operator<< (const T & msg)

Appends a message to the reporter.

Template Parameters
T

The type of the message to append.

Parameters
msg

The message to append.

Returns

Reference to the current reporter instance.

This operator overload enables the deferred reporter to accumulate expectation messages by appending the provided value to the internal message string.

If the argument is of an arithmetic type, it is first converted to a string using std::to_string before being appended. For all other types, the value is appended directly. This ensures that both numeric and string-like messages are handled appropriately and consistently.

Declaration at line 1770 of file detail.h, definition at line 90 of file details-inlines.h.

91 {
92 if constexpr (std::is_arithmetic_v<T>)
93 {
94 message_.append (std::to_string (msg));
95 }
96 else
97 {
98 message_.append (msg);
99 }
100 return *this;
101 }

Reference micro_os_plus::micro_test_plus::detail::deferred_reporter_base::message_.

Public Member Functions

value()

template <class Expr_T>
bool micro_os_plus::micro_test_plus::detail::deferred_reporter_base::value ()
inline nodiscard constexpr

Retrieves the result value.

Parameters

None.

Return Values
true

The reported condition was met.

false

The reported condition was not met.

Returns the result value associated with the report.

Definition at line 1786 of file detail.h.

1786 value () const
1787 {
1788 return value_;
1789 }

Reference micro_os_plus::micro_test_plus::detail::deferred_reporter_base::value_.

Referenced by micro_os_plus::micro_test_plus::detail::deferred_reporter_base::deferred_reporter_base.

Protected Member Attributes

abort_

template <class Expr_T>
bool micro_os_plus::micro_test_plus::detail::deferred_reporter_base::abort_ = false
protected

expr_

template <class Expr_T>
const Expr_T micro_os_plus::micro_test_plus::detail::deferred_reporter< Expr_T >::expr_ {}
protected

location_

template <class Expr_T>
const reflection::source_location micro_os_plus::micro_test_plus::detail::deferred_reporter_base::location_ {}
protected

message_

template <class Expr_T>
std::string micro_os_plus::micro_test_plus::detail::deferred_reporter_base::message_ {}
protected

String to collect the expectation message passed via operator<<().

Definition at line 1812 of file detail.h.

1812 std::string message_{};

Referenced by micro_os_plus::micro_test_plus::detail::deferred_reporter< Expr_T >::~deferred_reporter and micro_os_plus::micro_test_plus::detail::deferred_reporter_base::operator<<.

value_


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.