The test_reporter
Class Reference
Reporter to display test results, including operand values and types for failures. More...
Declaration
class micro_os_plus::micro_test_plus::test_reporter
Included Headers
#include <micro-os-plus/micro-test-plus.h>
Public Constructors Index
test_reporter ()=default | |
Default constructor for the test_reporter class. More... | |
Public Operators Index
test_reporter & | operator<< (bool v) |
Output operator for boolean values. More... | |
test_reporter & | operator<< (char *s) |
Output operator for a mutable character string. More... | |
test_reporter & | operator<< (char c) |
Output operator for a single character. More... | |
test_reporter & | operator<< (const char *s) |
Output operator for a constant character string. More... | |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::and_< Lhs_T, Rhs_T > &op) |
Output operator to display and() expressions. More... | |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::eq_< Lhs_T, Rhs_T > &op) |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::ge_< Lhs_T, Rhs_T > &op) |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::gt_< Lhs_T, Rhs_T > &op) |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::le_< Rhs_T, Lhs_T > &op) |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::lt_< Rhs_T, Lhs_T > &op) |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::ne_< Lhs_T, Rhs_T > &op) |
template <class T> | |
test_reporter & | operator<< (const detail::not_< T > &op) |
Output operator to display not() expressions. More... | |
template <class Expr_T> | |
test_reporter & | operator<< (const detail::nothrow_< Expr_T > &op) |
Output operator to display nothrow expressions. More... | |
template <class Lhs_T, class Rhs_T> | |
test_reporter & | operator<< (const detail::or_< Lhs_T, Rhs_T > &op) |
Output operator to display or() expressions. More... | |
template <class Expr_T, class Exception_T> | |
test_reporter & | operator<< (const detail::throws_< Expr_T, Exception_T > &op) |
Output operator to display throws expressions for a specific exception type. More... | |
template <class Expr_T> | |
test_reporter & | operator<< (const detail::throws_< Expr_T, void > &op) |
Output operator to display throws expressions for any exception. More... | |
template <class T> | |
test_reporter & | operator<< (const T &t) |
Output operator for types with a getter. More... | |
template <class T> | |
test_reporter & | operator<< (const type_traits::genuine_integral_value< T > &v) |
Output operator to display genuine integers, without the type suffix. More... | |
test_reporter & | operator<< (double v) |
Output operator for double values. More... | |
test_reporter & | operator<< (float v) |
Output operator for float values. More... | |
test_reporter & | operator<< (long double v) |
Output operator for long double values. More... | |
test_reporter & | operator<< (signed char c) |
Output operator for signed char values. More... | |
test_reporter & | operator<< (signed int v) |
Output operator for signed int values. More... | |
test_reporter & | operator<< (signed long long v) |
Output operator for signed long long values. More... | |
test_reporter & | operator<< (signed long v) |
Output operator for signed long values. More... | |
test_reporter & | operator<< (signed short v) |
Output operator for signed short values. More... | |
test_reporter & | operator<< (std::nullptr_t) |
Output operator for nullptr. More... | |
test_reporter & | operator<< (std::string_view sv) |
Output operator for std::string_view. More... | |
template < ... > | |
test_reporter & | operator<< (T &&t) |
Output operator to display containers. Iterates all members. More... | |
template <typename T> | |
test_reporter & | operator<< (T *v) |
Output operator to display any pointer. More... | |
test_reporter & | operator<< (test_reporter &(*func)(test_reporter &)) |
Output operator to display the endl. More... | |
test_reporter & | operator<< (unsigned char c) |
Output operator for unsigned char values. More... | |
test_reporter & | operator<< (unsigned int v) |
Output operator for unsigned int values. More... | |
test_reporter & | operator<< (unsigned long long v) |
Output operator for unsigned long long values. More... | |
test_reporter & | operator<< (unsigned long v) |
Output operator for unsigned long values. More... | |
test_reporter & | operator<< (unsigned short v) |
Output operator for unsigned short values. More... | |
Public Member Functions Index
void | begin_test_case (const char *name) |
Mark the beginning of a test case. More... | |
void | begin_test_suite (const char *name) |
Mark the beginning of a test suite. More... | |
auto | color (const bool cond) |
Selects the appropriate colour code based on a condition. More... | |
void | end_test_case (const char *name) |
Mark the end of a test case. More... | |
void | end_test_suite (test_suite_base &suite) |
Mark the end of a test suite. More... | |
void | endline (void) |
Inserts a line ending into the output buffer. More... | |
template <class Expr_T> | |
void | fail (Expr_T &expr, bool abort, std::string &message, const reflection::source_location &location) |
Report a failed condition. More... | |
void | flush (void) |
Flush the current buffered content. More... | |
void | output (void) |
Output the current buffered content. More... | |
template <class Expr_T> | |
void | pass (Expr_T &expr, std::string &message) |
Report a passed condition. More... | |
Protected Member Functions Index
void | output_fail_prefix_ (std::string &message, const reflection::source_location &location) |
Outputs the prefix for a failing condition. More... | |
void | output_fail_suffix_ (bool abort) |
Outputs the suffix for a failing condition. More... | |
void | output_pass_prefix_ (std::string &message) |
Outputs the prefix for a passing condition. More... | |
void | output_pass_suffix_ (void) |
Outputs the suffix for a passing condition. More... | |
Public Member Attributes Index
bool | add_empty_line { true } |
Controls whether to add an empty line between successful test cases. More... | |
verbosity_t | verbosity {} |
The verbosity level for test reporting. More... | |
Protected Member Attributes Index
colors | colors_ {} |
ANSI colour codes for output formatting. More... | |
bool | is_in_test_case_ = false |
Indicates whether the reporter is currently within a test case. More... | |
std::string | out_ {} |
Internal output buffer for accumulating report content. More... | |
Description
Reporter to display test results, including operand values and types for failures.
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 194 of file test-reporter.h.
Public Constructors
test_reporter()
| default |
Default constructor for the test_reporter class.
Definition at line 200 of file test-reporter.h.
Public Operators
operator<<()
|
Output operator for boolean values.
- Parameters
v The 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.
Declaration at line 260 of file test-reporter.h, definition at line 309 of file test-reporter.cpp.
operator<<()
|
Output operator for a mutable character string.
- Parameters
s The 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.
Declaration at line 251 of file test-reporter.h, definition at line 294 of file test-reporter.cpp.
operator<<()
|
Output operator for a single character.
- Parameters
c The 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.
Declaration at line 233 of file test-reporter.h, definition at line 264 of file test-reporter.cpp.
operator<<()
|
Output operator for a constant character string.
- Parameters
s The 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.
Declaration at line 242 of file test-reporter.h, definition at line 279 of file test-reporter.cpp.
operator<<()
|
Output operator to display and() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 538 of file test-reporter.h, definition at line 306 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display eq() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 460 of file test-reporter.h, definition at line 185 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display ge() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 499 of file test-reporter.h, definition at line 246 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display gt() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 486 of file test-reporter.h, definition at line 225 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display le() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 525 of file test-reporter.h, definition at line 286 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display lt() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 512 of file test-reporter.h, definition at line 265 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display ne() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 473 of file test-reporter.h, definition at line 205 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display not() expressions.
- Template Parameters
T The operand type.
- Parameters
op The 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.
Declaration at line 563 of file test-reporter.h, definition at line 342 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display nothrow expressions.
- Template Parameters
Expr_T The expression type.
- Parameters
op The 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.
Declaration at line 602 of file test-reporter.h, definition at line 398 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display or() expressions.
- Template Parameters
Lhs_T The left-hand side type. Rhs_T The right-hand side type.
- Parameters
op The 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.
Declaration at line 551 of file test-reporter.h, definition at line 326 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display throws expressions for a specific exception type.
- Template Parameters
Expr_T The expression type. Exception_T The exception type.
- Parameters
op The 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.
Declaration at line 578 of file test-reporter.h, definition at line 362 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display throws expressions for any exception.
- Template Parameters
Expr_T The expression type.
- Parameters
op The 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.
Declaration at line 590 of file test-reporter.h, definition at line 381 of file test-reporter-inlines.h.
operator<<()
|
Output operator for types with a getter.
- Template Parameters
T The type with a getter method.
- Parameters
t The object to output.
- Returns
Reference to the current test_reporter instance.
Definition at line 419 of file test-reporter.h.
operator<<()
|
Output operator to display genuine integers, without the type suffix.
- Template Parameters
T The underlying integral type.
- Parameters
v The 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.
Declaration at line 432 of file test-reporter.h, definition at line 135 of file test-reporter-inlines.h.
operator<<()
|
Output operator for double values.
- Parameters
v The 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.
Declaration at line 374 of file test-reporter.h, definition at line 513 of file test-reporter.cpp.
operator<<()
|
Output operator for float values.
- Parameters
v The 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.
Declaration at line 365 of file test-reporter.h, definition at line 497 of file test-reporter.cpp.
operator<<()
|
Output operator for long double values.
- Parameters
v The 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.
Declaration at line 383 of file test-reporter.h, definition at line 529 of file test-reporter.cpp.
operator<<()
|
Output operator for signed char values.
- Parameters
c The 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.
Declaration at line 275 of file test-reporter.h, definition at line 338 of file test-reporter.cpp.
operator<<()
|
Output operator for signed int values.
- Parameters
v The 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.
Declaration at line 311 of file test-reporter.h, definition at line 402 of file test-reporter.cpp.
operator<<()
|
Output operator for signed long long values.
- Parameters
v The 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.
Declaration at line 347 of file test-reporter.h, definition at line 465 of file test-reporter.cpp.
operator<<()
|
Output operator for signed long values.
- Parameters
v The 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.
Declaration at line 329 of file test-reporter.h, definition at line 433 of file test-reporter.cpp.
operator<<()
|
Output operator for signed short values.
- Parameters
v The 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.
Declaration at line 293 of file test-reporter.h, definition at line 370 of file test-reporter.cpp.
operator<<()
|
Output operator for nullptr.
- 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.
Declaration at line 267 of file test-reporter.h, definition at line 323 of file test-reporter.cpp.
operator<<()
|
Output operator for std::string_view.
- Parameters
sv The 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.
Declaration at line 224 of file test-reporter.h, definition at line 250 of file test-reporter.cpp.
operator<<()
|
Output operator to display containers. Iterates all members.
- Template Parameters
T The container type.
- Parameters
t The 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.
Declaration at line 447 of file test-reporter.h, definition at line 159 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display any pointer.
- Template Parameters
T The type of the pointer.
- Parameters
v The 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.
Declaration at line 395 of file test-reporter.h, definition at line 92 of file test-reporter-inlines.h.
operator<<()
|
Output operator to display the endl.
- Parameters
func Function 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.
Declaration at line 404 of file test-reporter.h, definition at line 206 of file test-reporter.cpp.
operator<<()
|
Output operator for unsigned char values.
- Parameters
c The 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.
Declaration at line 284 of file test-reporter.h, definition at line 354 of file test-reporter.cpp.
operator<<()
|
Output operator for unsigned int values.
- Parameters
v The 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.
Declaration at line 320 of file test-reporter.h, definition at line 417 of file test-reporter.cpp.
operator<<()
|
Output operator for unsigned long long values.
- Parameters
v The 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.
Declaration at line 356 of file test-reporter.h, definition at line 481 of file test-reporter.cpp.
operator<<()
|
Output operator for unsigned long values.
- Parameters
v The 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.
Declaration at line 338 of file test-reporter.h, definition at line 449 of file test-reporter.cpp.
operator<<()
|
Output operator for unsigned short values.
- Parameters
v The 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.
Declaration at line 302 of file test-reporter.h, definition at line 386 of file test-reporter.cpp.
Public Member Functions
begin_test_case()
|
Mark the beginning of a test case.
- Parameters
name The name of the test case.
- Returns
Nothing.
This method marks the beginning of a test case, setting the internal state to indicate that test output is now within a test case context. If there is pending output and the verbosity level is set to verbose, it ensures that output is properly separated and displayed, adding an empty line if necessary. The output buffer is cleared and the stream is flushed to guarantee that all previous output is visible before the new test case begins. This approach enhances the clarity and organisation of test results across all test cases and folders.
Declaration at line 658 of file test-reporter.h, definition at line 548 of file test-reporter.cpp.
begin_test_suite()
|
Mark the beginning of a test suite.
- Parameters
name The name of the test suite.
- Returns
Nothing.
This method marks the beginning of a test suite, ensuring that output is properly separated and clearly presented. If there is pending output, the stream is flushed and an empty line is added for clarity. For silent or quiet verbosity levels, output is suppressed. Otherwise, a message indicating the start of the test suite is displayed. This approach enhances the organisation and readability of test results across all test cases and folders.
Declaration at line 678 of file test-reporter.h, definition at line 657 of file test-reporter.cpp.
color()
| inlinenodiscard |
Selects the appropriate colour code based on a condition.
- Parameters
cond Boolean 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 213 of file test-reporter.h.
end_test_case()
|
Mark the end of a test case.
- Parameters
name The name of the test case.
- Returns
Nothing.
This method marks the end of a test case, summarising its outcome and outputting the results with appropriate formatting and colour coding. If any checks have failed, a failure message is displayed, including the number of successful and failed checks. For passing test cases, a success message is shown with the total number of checks. The output is adjusted according to the verbosity level, and additional spacing is managed for clarity. The output buffer is cleared and the stream is flushed to ensure all results are immediately visible, supporting clear and organised reporting across all test cases and folders.
Declaration at line 668 of file test-reporter.h, definition at line 580 of file test-reporter.cpp.
end_test_suite()
|
Mark the end of a test suite.
- Parameters
suite Reference to the test suite base.
- Returns
Nothing.
This method marks the end of a test suite, summarising the overall results and presenting them with appropriate formatting and colour coding. If the suite contains test cases and the verbosity is not set to quiet, an empty line is added for clarity. For suites with no failed checks and at least one successful check, a success message is displayed, including the number of checks and test cases. Otherwise, a failure message is shown, detailing the number of successful and failed checks, as well as the total number of test cases. The output is immediately flushed to ensure prompt and organised reporting across all test cases and folders.
Declaration at line 688 of file test-reporter.h, definition at line 689 of file test-reporter.cpp.
endline()
|
Inserts a line ending into the output buffer.
- Parameters
None.
- Returns
Nothing.
This method appends a newline character to the internal output buffer of the test_reporter
and immediately flushes the stream. This ensures that each line of test output is clearly separated and promptly displayed, enhancing the readability and organisation of test results across all test cases and folders.
Declaration at line 615 of file test-reporter.h, definition at line 222 of file test-reporter.cpp.
fail()
|
Report a failed condition.
- Template Parameters
Expr_T The expression type.
- Parameters
expr The evaluated expression. abort Whether to abort execution after failure. message The message to display. location The 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.
Declaration at line 647 of file test-reporter.h, definition at line 443 of file test-reporter-inlines.h.
flush()
|
Flush the current buffered content.
- Parameters
None.
- Returns
Nothing.
This method flushes the output buffer of the test_reporter
by synchronising it with the standard output stream. This guarantees that all pending test output is immediately written and visible, ensuring prompt and reliable reporting of test results across all test cases and folders.
Declaration at line 699 of file test-reporter.h, definition at line 236 of file test-reporter.cpp.
output()
|
Output the current buffered content.
- Parameters
None.
- Returns
Nothing.
This method writes the contents of the internal output buffer to the standard output stream without appending a newline character. After outputting the buffer, it is cleared to prepare for subsequent output. This approach ensures that test results are presented promptly and efficiently, supporting clear and organised reporting across all test cases and folders.
Declaration at line 710 of file test-reporter.h, definition at line 735 of file test-reporter.cpp.
pass()
|
Report a passed condition.
- Template Parameters
Expr_T The expression type.
- Parameters
expr The evaluated expression. message The 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.
Declaration at line 631 of file test-reporter.h, definition at line 419 of file test-reporter-inlines.h.
Protected Member Functions
output_fail_prefix_()
| protected |
Outputs the prefix for a failing condition.
- Parameters
message The message to display. location The source location of the failure.
- Returns
Nothing.
This method outputs the prefix for a failing test result, applying the appropriate colour formatting and symbols to clearly indicate failure. If the output occurs within a test case, additional indentation is applied for readability. The prefix includes a cross symbol (✗
), an optional message, and the label "FAILED". The source location is appended in parentheses, showing the file or folder name and line number where the failure occurred. Colour formatting is reset after the prefix to maintain consistent output style across all test cases and folders.
Declaration at line 757 of file test-reporter.h, definition at line 144 of file test-reporter.cpp.
output_fail_suffix_()
| protected |
Outputs the suffix for a failing condition.
- Parameters
abort Whether to abort execution after failure.
- Returns
Nothing.
This method outputs the suffix for a failing test result by closing the location information, appending an "aborted..." message if the test was aborted, and then adding a newline to the test output. The output stream is flushed to ensure immediate visibility. This approach guarantees that failure results are clearly separated, promptly reported, and easily distinguishable across all test cases and folders.
Declaration at line 768 of file test-reporter.h, definition at line 184 of file test-reporter.cpp.
output_pass_prefix_()
| protected |
Outputs the prefix for a passing condition.
- Parameters
message The message to display.
- Returns
Nothing.
This method outputs the prefix for a passing test result, applying the appropriate colour formatting and symbols to clearly indicate success. If the output occurs within a test case, additional indentation is applied for readability. The prefix includes a tick symbol (✓
) and, if provided, an associated message. Colour formatting is reset after the prefix to maintain consistent output style across all test cases and folders.
The prefix/suffix methods help shorten the code generated by the template methods.
Declaration at line 735 of file test-reporter.h, definition at line 94 of file test-reporter.cpp.
output_pass_suffix_()
| protected |
Outputs the suffix for a passing condition.
- Parameters
None.
- Returns
Nothing.
The endl
function acts as a stream manipulator for the test_reporter
, inserting a line ending into the output buffer and flushing the current content if necessary. This ensures that test report output is clearly separated and formatted, improving readability and professionalism in the presentation of test results.
Using endl
in conjunction with the test_reporter
output operators provides a familiar and convenient mechanism for managing line breaks, similar to standard C++ stream manipulators.
The prefix/suffix methods help shorten the code generated by the template methods.
Declaration at line 746 of file test-reporter.h, definition at line 125 of file test-reporter.cpp.
Public Member Attributes
add_empty_line
|
Controls whether to add an empty line between successful test cases.
Used to nicely format the output.
Definition at line 719 of file test-reporter.h.
verbosity
|
The verbosity level for test reporting.
Definition at line 724 of file test-reporter.h.
Protected Member Attributes
colors_
| protected |
ANSI colour codes for output formatting.
Definition at line 773 of file test-reporter.h.
is_in_test_case_
| protected |
Indicates whether the reporter is currently within a test case.
Definition at line 783 of file test-reporter.h.
out_
| protected |
Internal output buffer for accumulating report content.
Definition at line 778 of file test-reporter.h.
The documentation for this class was generated from the following files:
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.