reporter.cpp File
C++ source file with implementations for the µTest++ test reporter member functions. More...
Included Headers
Namespaces Index
| namespace | micro_os_plus |
|
The primary namespace for the µOS++ framework. More... | |
| namespace | micro_test_plus |
|
Primary namespace for the µTest++ testing framework. More... | |
| namespace | detail |
|
Internal implementation details for the µTest++ framework. More... | |
| namespace | anonymous{reporter.cpp} |
|
Local helpers of the reporter base class. More... | |
Functions Index
| reporter & | endl (reporter &stream) |
|
Output stream manipulator for ending a line in test reports. More... | |
| void | format_skipped (size_t count, char(&message)[fragment_size]) |
|
Formats the number of items skipped by the filter. More... | |
| constexpr const char * | plural (size_t count) noexcept |
|
Returns the plural suffix for a count. More... | |
| void | write_without_colours (FILE *file, std::string_view text) |
|
Writes a text to a file, without the ANSI colour sequences. More... | |
Variables Index
| constexpr size_t | fragment_size = 21 + (std::numeric_limits<size_t>::digits10 + 1) |
|
Size of the array that receives a fragment of the totals. More... | |
Description
C++ source file with implementations for the µTest++ test reporter member functions.
This source file contains the core implementations for the test reporting facilities of the µTest++ framework. It provides lifecycle and utility behaviour for reporters, including output-file handling, informational banner emission, buffering helpers, stream operators, the formatting of the totals and of the elapsed times, and pass/fail dispatch to reporter-specific prefix/suffix hooks. The command-line options are parsed by runner_options.
Concrete formatting behaviour is implemented by derived reporters (reporter_human and reporter_tap).
All definitions reside within the micro_os_plus::micro_test_plus::detail namespace, since the reporters are internal to the framework.
This file must be included when building the µTest++ library.
Functions
endl()
|
Output stream manipulator for ending a line in test reports.
Calls reporter::end_line(), which appends a line ending to the internal buffer. Unlike std::endl, it does not flush; the buffer is written later, by the concrete reporters.
- Parameters
-
stream Reference to the reporter instance.
- Returns
Reference to the same reporter instance, enabling chaining of output operations.
The endl function calls reporter::end_line(), which appends a newline character to the buffer of the specified reporter.
Definition at line 218 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::end_line and micro_os_plus::micro_test_plus::detail::endl.
Referenced by micro_os_plus::micro_test_plus::detail::endl, micro_os_plus::micro_test_plus::detail::reporter_human::fail_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_prefix, micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_suffix, micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix, micro_os_plus::micro_test_plus::detail::reporter_human::output_pass_suffix, micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_suffix and micro_os_plus::micro_test_plus::detail::reporter_tap::pass_without_text.
format_skipped()
|
Formats the number of items skipped by the filter.
The text is ", <count> skipped", appended to the count of the items, or empty when no item was skipped, so that the totals lines of the runs without a filter are not longer.
- Parameters
-
count The number of skipped items.
message The character array that receives the null-terminated text.
- Returns
Nothing.
Definition at line 874 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::format_skipped, micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::fragment_size and MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::format_skipped.
plural()
| constexpr noexcept |
Returns the plural suffix for a count.
The totals lines are in English, where only the count 1 takes the singular form.
- Parameters
-
count The count that precedes the noun.
- Returns
"" for 1, and "s" otherwise.
Definition at line 854 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::plural.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::plural.
write_without_colours()
|
Writes a text to a file, without the ANSI colour sequences.
The text may contain ANSI colour sequences, added when the console is a terminal, which must not reach the file. They are removed while writing: each ESC [, followed by any digits and semicolons, and terminated by m, is skipped, and the text between the sequences is written unchanged. Any other use of ESC is written as is. No line ending is appended.
- Parameters
-
file The file to write to; must not be null.
text The text to write.
- Returns
Nothing.
Definition at line 113 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::write_without_colours.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::write_without_colours.
Variables
fragment_size
| constexpr |
Size of the array that receives a fragment of the totals.
Large enough for ", N test cases failed", the longest fragment (20 characters and the count), and the terminator, with the count of the largest size_t value (10 digits on 32-bit targets, 20 on 64-bit ones, as in ", 18446744073709551615 test cases failed").
Definition at line 840 of file reporter.cpp.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{reporter.cpp}::format_skipped.
File Listing
The file content with the documentation metadata removed is:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.