micro-test-plus 3.3.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::test_reporter Class Referenceabstract

Reporter to display test results, including operand values and types for failures. More...

#include <micro-os-plus/micro-test-plus.h>

Inheritance diagram for micro_os_plus::micro_test_plus::test_reporter:

Public Member Functions

virtual ~test_reporter ()
 Default constructor for the test_reporter class.
virtual void begin_test (size_t test_suites_count)=0
 Mark the beginning of a test.
virtual void begin_test_case (const char *name)=0
 Mark the beginning of a test case.
virtual void begin_test_suite (const char *name)=0
 Mark the beginning of a test suite.
auto color (const bool cond)
 Selects the appropriate colour code based on a condition.
virtual void end_test (test_runner &runner)=0
 Mark the end of a test.
virtual void end_test_case (const char *name)=0
 Mark the end of a test case.
virtual void end_test_suite (test_suite_base &suite)=0
 Mark the end of a test suite.
virtual void endline (void)=0
 Inserts a line ending into the output buffer.
template<class Expr_T>
void fail (Expr_T &expr, bool abort, std::string &message, const reflection::source_location &location)
 Report a failed condition.
virtual void flush (void)=0
 Flush the current buffered content.
test_reporteroperator<< (bool v)
 Output operator for boolean values.
test_reporteroperator<< (char *s)
 Output operator for a mutable character string.
test_reporteroperator<< (char c)
 Output operator for a single character.
test_reporteroperator<< (const char *s)
 Output operator for a constant character string.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::and_< Lhs_T, Rhs_T > &op)
 Output operator to display and() expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::eq_< Lhs_T, Rhs_T > &op)
 Output operator to display eq() expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::ge_< Lhs_T, Rhs_T > &op)
 Output operator to display ge() expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::gt_< Lhs_T, Rhs_T > &op)
 Output operator to display gt() expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::le_< Rhs_T, Lhs_T > &op)
 Output operator to display le() expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::lt_< Rhs_T, Lhs_T > &op)
 Output operator to display lt() expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::ne_< Lhs_T, Rhs_T > &op)
 Output operator to display ne() expressions.
template<class T>
test_reporteroperator<< (const detail::not_< T > &op)
 Output operator to display not() expressions.
template<class Expr_T>
test_reporteroperator<< (const detail::nothrow_< Expr_T > &op)
 Output operator to display nothrow expressions.
template<class Lhs_T, class Rhs_T>
test_reporteroperator<< (const detail::or_< Lhs_T, Rhs_T > &op)
 Output operator to display or() expressions.
template<class Expr_T, class Exception_T>
test_reporteroperator<< (const detail::throws_< Expr_T, Exception_T > &op)
 Output operator to display throws expressions for a specific exception type.
template<class Expr_T>
test_reporteroperator<< (const detail::throws_< Expr_T, void > &op)
 Output operator to display throws expressions for any exception.
template<class T>
test_reporteroperator<< (const T &t)
 Output operator for types with a getter.
template<class T>
test_reporteroperator<< (const type_traits::genuine_integral_value< T > &v)
 Output operator to display genuine integers, without the type suffix.
test_reporteroperator<< (double v)
 Output operator for double values.
test_reporteroperator<< (float v)
 Output operator for float values.
test_reporteroperator<< (long double v)
 Output operator for long double values.
test_reporteroperator<< (signed char c)
 Output operator for signed char values.
test_reporteroperator<< (signed int v)
 Output operator for signed int values.
test_reporteroperator<< (signed long long v)
 Output operator for signed long long values.
test_reporteroperator<< (signed long v)
 Output operator for signed long values.
test_reporteroperator<< (signed short v)
 Output operator for signed short values.
test_reporteroperator<< (std::nullptr_t)
 Output operator for nullptr.
test_reporteroperator<< (std::string_view sv)
 Output operator for std::string_view.
template<class T, type_traits::requires_t< type_traits::is_container_v< T > and not type_traits::has_npos_v< T > > = 0>
test_reporteroperator<< (T &&t)
 Output operator to display containers. Iterates all members.
template<typename T>
test_reporteroperator<< (T *v)
 Output operator to display any pointer.
test_reporteroperator<< (test_reporter &(*func)(test_reporter &))
 Output operator to display the endl.
test_reporteroperator<< (unsigned char c)
 Output operator for unsigned char values.
test_reporteroperator<< (unsigned int v)
 Output operator for unsigned int values.
test_reporteroperator<< (unsigned long long v)
 Output operator for unsigned long long values.
test_reporteroperator<< (unsigned long v)
 Output operator for unsigned long values.
test_reporteroperator<< (unsigned short v)
 Output operator for unsigned short values.
virtual void output (void)=0
 Output the current buffered content.
template<class Expr_T>
void pass (Expr_T &expr, std::string &message)
 Report a passed condition.

Public Attributes

bool add_empty_line { true }
 Controls whether to add an empty line between successful test cases.
verbosity_t verbosity {}
 The verbosity level for test reporting.

Protected Member Functions

virtual void output_fail_prefix_ (std::string &message, const bool hasExpression, const reflection::source_location &location)=0
 Outputs the prefix for a failing condition.
virtual void output_fail_suffix_ (const reflection::source_location &location, bool abort)=0
 Outputs the suffix for a failing condition.
virtual void output_pass_prefix_ (std::string &message)=0
 Outputs the prefix for a passing condition.
virtual void output_pass_suffix_ (void)=0
 Outputs the suffix for a passing condition.

Protected Attributes

colors colors_ {}
 ANSI colour codes for output formatting.
bool is_in_test_case_ = false
 Indicates whether the reporter is currently within a test case.
std::string out_ {}
 Internal output buffer for accumulating report content.

Detailed Description

The test_reporter class is responsible for formatting and presenting test results within the µTest++ framework. It provides a comprehensive suite of output operators for a wide range of data types, containers, and comparator expressions, enabling detailed and informative reporting of test outcomes.

For failed tests, the reporter prints the actual values of the operands along with their types, supporting precise diagnostics and efficient debugging. The class supports multiple verbosity levels and colour-coded output to distinguish between successful and failed tests, thereby enhancing the clarity and professionalism of test reports.

The test_reporter also offers methods for reporting the commencement and completion of test cases and suites, as well as for handling pass and fail conditions. Additional features include output stream manipulators, support for exception-related expressions, and configurable formatting options.

All members and methods are defined within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

Definition at line 202 of file test-reporter.h.

Constructor & Destructor Documentation

◆ ~test_reporter()

micro_os_plus::micro_test_plus::test_reporter::~test_reporter ( )
virtualdefault

Member Function Documentation

◆ begin_test()

virtual void micro_os_plus::micro_test_plus::test_reporter::begin_test ( size_t test_suites_count)
pure virtual
Parameters
test_suites_countThe number of test suites.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

◆ begin_test_case()

virtual void micro_os_plus::micro_test_plus::test_reporter::begin_test_case ( const char * name)
pure virtual
Parameters
nameThe name of the test case.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

◆ begin_test_suite()

virtual void micro_os_plus::micro_test_plus::test_reporter::begin_test_suite ( const char * name)
pure virtual
Parameters
nameThe name of the test suite.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

◆ color()

auto micro_os_plus::micro_test_plus::test_reporter::color ( const bool cond)
inlinenodiscard
Parameters
condBoolean value indicating pass (true) or fail (false).
Returns
The corresponding ANSI colour code as a string.

Returns the ANSI colour code for pass or fail, depending on the boolean condition provided.

Definition at line 221 of file test-reporter.h.

222 {
223 return cond ? colors_.pass : colors_.fail;
224 }
colors colors_
ANSI colour codes for output formatting.

References colors_.

Referenced by operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), operator<<(), and operator<<().

◆ end_test()

virtual void micro_os_plus::micro_test_plus::test_reporter::end_test ( test_runner & runner)
pure virtual
Parameters
runnerReference to the test runner.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

References micro_os_plus::micro_test_plus::runner.

◆ end_test_case()

virtual void micro_os_plus::micro_test_plus::test_reporter::end_test_case ( const char * name)
pure virtual
Parameters
nameThe name of the test case.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

◆ end_test_suite()

virtual void micro_os_plus::micro_test_plus::test_reporter::end_test_suite ( test_suite_base & suite)
pure virtual
Parameters
suiteReference to the test suite base.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

◆ endline()

virtual void micro_os_plus::micro_test_plus::test_reporter::endline ( void )
pure virtual

◆ fail()

template<class Expr_T>
void micro_os_plus::micro_test_plus::test_reporter::fail ( Expr_T & expr,
bool abort,
std::string & message,
const reflection::source_location & location )
Template Parameters
Expr_TThe expression type.
Parameters
exprThe evaluated expression.
abortWhether to abort execution after failure.
messageThe message to display.
locationThe source location of the failure.
Returns
Nothing.

This function reports a test failure and formats the output in a clear and consistent manner. It provides contextual information, including the precise source location, and appends the evaluated expression when applicable. The failure handling process ensures uniformity in the presentation of unsuccessful test cases, aiding in the rapid identification and diagnosis of issues within test reports.

Definition at line 445 of file test-reporter-inlines.h.

447 {
449
450 const bool hasExpression = type_traits::is_op_v<Expr_T>;
451 output_fail_prefix_ (message, hasExpression, location);
452
453 if constexpr (type_traits::is_op_v<Expr_T>)
454 {
455 *this << expr;
456 }
457
458 output_fail_suffix_ (location, abort);
459 }
virtual void output_fail_suffix_(const reflection::source_location &location, bool abort)=0
Outputs the suffix for a failing condition.
virtual void output_fail_prefix_(std::string &message, const bool hasExpression, const reflection::source_location &location)=0
Outputs the prefix for a failing condition.
size_t index
The test suite index, counting from 1.
Definition test-suite.h:341
struct micro_os_plus::micro_test_plus::test_suite_base::@025050103341037176303320301005170305141235061044 current_test_case
Structure holding the current test case's check counters.
constexpr auto is_op_v
Variable template to determine if a type derives from op.
test_suite_base * current_test_suite
Global pointer references the currently active test suite.

References micro_os_plus::micro_test_plus::current_test_suite, micro_os_plus::micro_test_plus::type_traits::is_op_v, output_fail_prefix_(), and output_fail_suffix_().

◆ flush()

virtual void micro_os_plus::micro_test_plus::test_reporter::flush ( void )
pure virtual

◆ operator<<() [1/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( bool v)
Parameters
vThe boolean value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified boolean value to the internal output buffer of the test_reporter. It enables clear and direct streaming of boolean results into the reporter, supporting precise and readable formatting of test output across all test cases and folders.

Definition at line 168 of file test-reporter.cpp.

170 {
171 out_.append (v ? "true" : "false");
172 return *this;
173 }
std::string out_
Internal output buffer for accumulating report content.

References out_.

◆ operator<<() [2/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( char * s)
Parameters
sThe string to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the contents of the provided modifiable C-style string to the internal output buffer of the test_reporter. It enables efficient streaming of mutable string data into the reporter, supporting clear and flexible formatting of test output across all test cases and folders.

Definition at line 153 of file test-reporter.cpp.

155 {
156 out_.append (s);
157 return *this;
158 }

References out_.

◆ operator<<() [3/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( char c)
Parameters
cThe character to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the specified character to the internal output buffer of the test_reporter. It enables efficient streaming of individual characters into the reporter, supporting precise and flexible formatting of test output across all test cases and folders.

Definition at line 123 of file test-reporter.cpp.

125 {
126 out_.append (1, c);
127 return *this;
128 }

References out_.

◆ operator<<() [4/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const char * s)
Parameters
sThe string to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the contents of the provided C-style string to the internal output buffer of the test_reporter. It enables efficient streaming of string literals and character arrays into the reporter, supporting clear and flexible formatting of test output across all test cases and folders.

Definition at line 138 of file test-reporter.cpp.

140 {
141 out_.append (s);
142 return *this;
143 }

References out_.

◆ operator<<() [5/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::and_< Lhs_T, Rhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe logical conjunction (AND) expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output logical conjunction (AND) expressions in a clear and structured format.

The left-hand side and right-hand side expressions are enclosed in parentheses and separated by the word "and", with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This presentation assists in quickly identifying the components of logical assertions and facilitates efficient debugging of test failures involving compound conditions.

Definition at line 305 of file test-reporter-inlines.h.

307 {
308 return (*this << '(' << op.lhs () << color (op) << " and " << colors_.none
309 << op.rhs () << ')');
310 }
auto color(const bool cond)
Selects the appropriate colour code based on a condition.

References color(), colors_, micro_os_plus::micro_test_plus::detail::and_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::and_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [6/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::eq_< Lhs_T, Rhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe equality comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output equality comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the equality operator (==), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in equality assertions and facilitates efficient debugging of test failures.

Definition at line 184 of file test-reporter-inlines.h.

186 {
187 return (*this << color (op) << op.lhs () << " == " << op.rhs ()
188 << colors_.none);
189 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [7/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::ge_< Lhs_T, Rhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe greater-than-or-equal-to comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output greater-than-or-equal-to comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the greater-than-or-equal-to operator (>=), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in greater-than-or-equal-to assertions and facilitates efficient debugging of test failures.

Definition at line 245 of file test-reporter-inlines.h.

247 {
248 return (*this << color (op) << op.lhs () << " >= " << op.rhs ()
249 << colors_.none);
250 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [8/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::gt_< Lhs_T, Rhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe greater-than comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output greater-than comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the greater-than operator (>), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in greater-than assertions and facilitates efficient debugging of test failures.

Definition at line 224 of file test-reporter-inlines.h.

226 {
227 return (*this << color (op) << op.lhs () << " > " << op.rhs ()
228 << colors_.none);
229 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [9/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::le_< Rhs_T, Lhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe less-than-or-equal-to comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output less-than-or-equal-to comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the less-than-or-equal-to operator (<=), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in less-than-or-equal-to assertions and facilitates efficient debugging of test failures.

Definition at line 285 of file test-reporter-inlines.h.

287 {
288 return (*this << color (op) << op.lhs () << " <= " << op.rhs ()
289 << colors_.none);
290 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [10/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::lt_< Rhs_T, Lhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe less-than comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output less-than comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the less-than operator (<), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in less-than assertions and facilitates efficient debugging of test failures.

Definition at line 264 of file test-reporter-inlines.h.

266 {
267 return (*this << color (op) << op.lhs () << " < " << op.rhs ()
268 << colors_.none);
269 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [11/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::ne_< Lhs_T, Rhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe inequality comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output inequality comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the inequality operator (!=), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in inequality assertions and facilitates efficient debugging of test failures.

Definition at line 204 of file test-reporter-inlines.h.

206 {
207 return (*this << color (op) << op.lhs () << " != " << op.rhs ()
208 << colors_.none);
209 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [12/36]

template<class T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::not_< T > & op)
Template Parameters
TThe operand type.
Parameters
opThe logical negation expression.
Returns
Reference to the current test_reporter instance.

This operator overload enhances readability and clarity by formatting the output when handling negated expressions. It applies colour styling for improved distinction and appends the negated value accordingly, ensuring that logical negations are clearly represented in test reports and diagnostics.

Definition at line 341 of file test-reporter-inlines.h.

343 {
344 return (*this << color (op) << "not " << op.value () << colors_.none);
345 }

References color(), colors_, and micro_os_plus::micro_test_plus::detail::not_< T >::value().

◆ operator<<() [13/36]

template<class Expr_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::nothrow_< Expr_T > & op)
Template Parameters
Expr_TThe expression type.
Parameters
opThe nothrow comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload formats output for expressions that do not throw exceptions. It applies colour styling for clarity and ensures a structured and concise representation of exception safety within test reports.

The output highlights the nothrow qualifier, making it immediately apparent when an expression is guaranteed not to throw, thereby improving the readability and professionalism of the test output.

Definition at line 397 of file test-reporter-inlines.h.

399 {
400 return (*this << color (op) << "nothrow" << colors_.none);
401 }

References color(), and colors_.

◆ operator<<() [14/36]

template<class Lhs_T, class Rhs_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::or_< Lhs_T, Rhs_T > & op)
Template Parameters
Lhs_TThe left-hand side type.
Rhs_TThe right-hand side type.
Parameters
opThe logical disjunction (OR) expression.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output logical disjunction (OR) expressions in a clear and structured format.

The left-hand side and right-hand side expressions are enclosed in parentheses and separated by the word "or", with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This presentation assists in quickly identifying the components of logical assertions and facilitates efficient debugging of test failures involving compound conditions.

Definition at line 325 of file test-reporter-inlines.h.

327 {
328 return (*this << '(' << op.lhs () << color (op) << " or " << colors_.none
329 << op.rhs () << ')');
330 }

References color(), colors_, micro_os_plus::micro_test_plus::detail::or_< Lhs_T, Rhs_T >::lhs(), and micro_os_plus::micro_test_plus::detail::or_< Lhs_T, Rhs_T >::rhs().

◆ operator<<() [15/36]

template<class Expr_T, class Exception_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::throws_< Expr_T, Exception_T > & op)
Template Parameters
Expr_TThe expression type.
Exception_TThe exception type.
Parameters
opThe throws comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload provides structured output for expressions that may throw exceptions. It applies colour styling for clarity and includes the exception type name for precise identification.

When invoked, the output highlights the throws qualifier along with the specific exception type, making it immediately apparent which exception is expected. This enhances the readability and professionalism of test reports, and assists in the precise identification and debugging of exception-related test cases.

Definition at line 361 of file test-reporter-inlines.h.

363 {
364 return (*this << color (op) << "throws<"
366 << colors_.none);
367 }
constexpr auto type_name(void) -> std::string_view
Extract the type name from the __PRETTY_FUNCTION__ macro.

References color(), colors_, and micro_os_plus::micro_test_plus::reflection::type_name().

◆ operator<<() [16/36]

template<class Expr_T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const detail::throws_< Expr_T, void > & op)
Template Parameters
Expr_TThe expression type.
Parameters
opThe throws comparator expression.
Returns
Reference to the current test_reporter instance.

This operator overload formats output for expressions that may throw exceptions. It applies colour styling for clarity and ensures a structured representation of the exception handling mechanism.

When invoked, the output highlights the throws qualifier, making it immediately apparent when an expression is expected to throw, thereby improving the readability and professionalism of the test output.

Definition at line 380 of file test-reporter-inlines.h.

382 {
383 return (*this << color (op) << "throws" << colors_.none);
384 }

References color(), and colors_.

◆ operator<<() [17/36]

template<class T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const T & t)
Template Parameters
TThe type with a getter method.
Parameters
tThe object to output.
Returns
Reference to the current test_reporter instance.

References micro_os_plus::micro_test_plus::type_traits::has_npos_v.

◆ operator<<() [18/36]

template<class T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( const type_traits::genuine_integral_value< T > & v)
Template Parameters
TThe underlying integral type.
Parameters
vThe strongly-typed integral value to output.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output strongly-typed integral values in a clear and consistent decimal format.

The value is converted to a string using std::to_string after being cast to long long, ensuring accurate formatting and compatibility across platforms. The resulting string is appended to the internal output buffer, allowing integral values to be included in test reports and diagnostics.

This approach ensures precise and unambiguous representation of integral values, which is particularly advantageous for verifying test results and facilitating debugging.

Definition at line 134 of file test-reporter-inlines.h.

136 {
137 out_.append (std::to_string (static_cast<long long> (v.get ())));
138 return *this;
139 }

References micro_os_plus::micro_test_plus::type_traits::genuine_integral_value< T >::get(), and out_.

◆ operator<<() [19/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( double v)
Parameters
vThe double value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified double-precision floating-point value to the internal output buffer of the test_reporter. It enables precise and readable streaming of double values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 372 of file test-reporter.cpp.

374 {
375 out_.append (std::to_string (v));
376 return *this;
377 }

References out_.

◆ operator<<() [20/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( float v)
Parameters
vThe float value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified floating-point value to the internal output buffer of the test_reporter, followed by the character 'f' to indicate a float type. It enables precise and readable streaming of float values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 356 of file test-reporter.cpp.

358 {
359 out_.append (std::to_string (v));
360 out_.append ("f");
361 return *this;
362 }

References out_.

◆ operator<<() [21/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( long double v)
Parameters
vThe long double value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified long double-precision floating-point value to the internal output buffer of the test_reporter, followed by the character 'l' to indicate a long double type. It enables precise and readable streaming of long double values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 388 of file test-reporter.cpp.

390 {
391 out_.append (std::to_string (v));
392 out_.append ("l");
393 return *this;
394 }

References out_.

◆ operator<<() [22/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( signed char c)
Parameters
cThe signed char value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified signed character to the internal output buffer of the test_reporter. It enables precise and readable streaming of character values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 197 of file test-reporter.cpp.

199 {
200 out_.append (std::to_string (c));
201 out_.append ("c");
202 return *this;
203 }

References out_.

◆ operator<<() [23/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( signed int v)
Parameters
vThe signed int value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified signed integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of signed integer values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 261 of file test-reporter.cpp.

263 {
264 out_.append (std::to_string (v));
265 return *this;
266 }

References out_.

◆ operator<<() [24/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( signed long long v)
Parameters
vThe signed long long value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified signed long long integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of signed long long values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 324 of file test-reporter.cpp.

326 {
327 out_.append (std::to_string (v));
328 out_.append ("ll");
329 return *this;
330 }

References out_.

◆ operator<<() [25/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( signed long v)
Parameters
vThe signed long value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified signed long integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of signed long values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 292 of file test-reporter.cpp.

294 {
295 out_.append (std::to_string (v));
296 out_.append ("l");
297 return *this;
298 }

References out_.

◆ operator<<() [26/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( signed short v)
Parameters
vThe signed short value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified signed short integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of signed short values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 229 of file test-reporter.cpp.

231 {
232 out_.append (std::to_string (v));
233 out_.append ("s");
234 return *this;
235 }

References out_.

◆ operator<<() [27/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( std::nullptr_t )
Returns
Reference to the current test_reporter instance.

This operator overload appends the string "nullptr" to the internal output buffer of the test_reporter. It enables clear and explicit streaming of null pointer values into the reporter, supporting precise and readable formatting of test output across all test cases and folders.

Definition at line 182 of file test-reporter.cpp.

184 {
185 out_.append ("nullptr");
186 return *this;
187 }

References out_.

◆ operator<<() [28/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( std::string_view sv)
Parameters
svThe string view to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the contents of the provided std::string_view to the internal output buffer of the test_reporter. It enables seamless streaming of string data into the reporter, supporting clear and efficient formatting of test output across all test cases and folders.

Definition at line 109 of file test-reporter.cpp.

111 {
112 out_.append (sv);
113 return *this;
114 }

References out_.

◆ operator<<() [29/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( T && t)
Template Parameters
TThe container type.
Parameters
tThe container to output.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output container types in a structured and readable format.

The contents of the container are enclosed in curly braces and each element is separated by a comma and a space. The operator iterates over the container, formatting each element in sequence, which ensures clarity and consistency in test reports and diagnostics.

This approach provides a clear visual representation of container contents, making it easier to interpret test results and debug issues involving collections of values.

Definition at line 158 of file test-reporter-inlines.h.

160 {
161 *this << '{';
162 auto first = true;
163 for (const auto& arg : t)
164 {
165 *this << (first ? "" : ", ") << arg;
166 first = false;
167 }
168 *this << '}';
169 return *this;
170 }

◆ operator<<() [30/36]

template<typename T>
test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( T * v)
Template Parameters
TThe type of the pointer.
Parameters
vThe pointer value to output.
Returns
Reference to the current test_reporter instance.

This operator overload enables the test_reporter to output pointer values in a consistent and readable hexadecimal format.

The pointer is formatted as a string using snprintf with the p format specifier, ensuring portability across platforms. The resulting string is appended to the internal output buffer, allowing pointer values to be included in test reports and diagnostics.

This approach provides clear and unambiguous representation of pointer addresses, which is particularly useful for debugging and verifying pointer-related test cases.

Definition at line 91 of file test-reporter-inlines.h.

93 {
94 char buff[20];
95 snprintf (buff, sizeof (buff), "%p", reinterpret_cast<void*> (v));
96 out_.append (buff);
97
98 return *this;
99 }

References out_.

◆ operator<<() [31/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( test_reporter &(* func )(test_reporter &))
Parameters
funcFunction pointer to the stream manipulator.
Returns
Reference to the current test_reporter instance.

This operator overload enables manipulators, such as endl, to be used with the test_reporter stream in a manner similar to standard C++ streams. When a manipulator function is passed, it is invoked with the current test_reporter instance, allowing for seamless integration of stream operations and improved readability of test output across all test cases and folders.

Definition at line 93 of file test-reporter.cpp.

95 {
96 // Call the endl function.
97 (*func) (*this);
98 return *this;
99 }

◆ operator<<() [32/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( unsigned char c)
Parameters
cThe unsigned char value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified unsigned character to the internal output buffer of the test_reporter. It enables precise and readable streaming of unsigned character values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 213 of file test-reporter.cpp.

215 {
216 out_.append (std::to_string (static_cast<int> (c)));
217 out_.append ("uc");
218 return *this;
219 }

References out_.

◆ operator<<() [33/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( unsigned int v)
Parameters
vThe unsigned int value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified unsigned integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of unsigned integer values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 276 of file test-reporter.cpp.

278 {
279 out_.append (std::to_string (v));
280 out_.append ("u");
281 return *this;
282 }

References out_.

◆ operator<<() [34/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( unsigned long long v)
Parameters
vThe unsigned long long value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified unsigned long long integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of unsigned long long values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 340 of file test-reporter.cpp.

342 {
343 out_.append (std::to_string (v));
344 out_.append ("ull");
345 return *this;
346 }

References out_.

◆ operator<<() [35/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( unsigned long v)
Parameters
vThe unsigned long value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified unsigned long integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of unsigned long values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 308 of file test-reporter.cpp.

310 {
311 out_.append (std::to_string (v));
312 out_.append ("ul");
313 return *this;
314 }

References out_.

◆ operator<<() [36/36]

test_reporter & micro_os_plus::micro_test_plus::test_reporter::operator<< ( unsigned short v)
Parameters
vThe unsigned short value to output.
Returns
Reference to the current test_reporter instance.

This operator overload appends the string representation of the specified unsigned short integer to the internal output buffer of the test_reporter. It enables precise and readable streaming of unsigned short values into the reporter, supporting clear formatting of test output across all test cases and folders.

Definition at line 245 of file test-reporter.cpp.

247 {
248 out_.append (std::to_string (static_cast<long> (v)));
249 out_.append ("us");
250 return *this;
251 }

References out_.

◆ output()

virtual void micro_os_plus::micro_test_plus::test_reporter::output ( void )
pure virtual

◆ output_fail_prefix_()

virtual void micro_os_plus::micro_test_plus::test_reporter::output_fail_prefix_ ( std::string & message,
const bool hasExpression,
const reflection::source_location & location )
protectedpure virtual
Parameters
messageThe message to display.
hasExpressionWhether the failure is associated with an expression.
locationThe source location of the failure.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

Referenced by fail().

◆ output_fail_suffix_()

virtual void micro_os_plus::micro_test_plus::test_reporter::output_fail_suffix_ ( const reflection::source_location & location,
bool abort )
protectedpure virtual
Parameters
locationThe source location of the failure.
abortWhether to abort execution after failure.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

Referenced by fail().

◆ output_pass_prefix_()

virtual void micro_os_plus::micro_test_plus::test_reporter::output_pass_prefix_ ( std::string & message)
protectedpure virtual
Parameters
messageThe message to display.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

Referenced by pass().

◆ output_pass_suffix_()

virtual void micro_os_plus::micro_test_plus::test_reporter::output_pass_suffix_ ( void )
protectedpure virtual
Parameters
None.
Returns
Nothing.

Implemented in micro_os_plus::micro_test_plus::test_reporter_basic, and micro_os_plus::micro_test_plus::test_reporter_tap.

Referenced by pass().

◆ pass()

template<class Expr_T>
void micro_os_plus::micro_test_plus::test_reporter::pass ( Expr_T & expr,
std::string & message )
Template Parameters
Expr_TThe expression type.
Parameters
exprThe evaluated expression.
messageThe message to display.
Returns
Nothing.

This operator overload formats output for expressions that do not throw exceptions. It applies colour styling for clarity and ensures a structured representation of exception safety.

When invoked, the function outputs a pass prefix, followed by either the provided message or, if the message is empty, the evaluated expression itself. It then appends a pass suffix to complete the output. This approach guarantees that successful test outcomes are presented in a clear and consistent manner, enhancing the readability and professionalism of test reports.

Definition at line 419 of file test-reporter-inlines.h.

420 {
422
423 output_pass_prefix_ (message);
424
425 if (message.empty ())
426 {
427 // If there is no message, display the evaluated expression.
428 *this << expr;
429 }
430
432 }
virtual void output_pass_suffix_(void)=0
Outputs the suffix for a passing condition.
virtual void output_pass_prefix_(std::string &message)=0
Outputs the prefix for a passing condition.

References micro_os_plus::micro_test_plus::current_test_suite, output_pass_prefix_(), and output_pass_suffix_().

Member Data Documentation

◆ add_empty_line

◆ colors_

◆ is_in_test_case_

◆ out_

◆ verbosity


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