micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::reporter_tap Class Referencefinal

TAP (Test Anything Protocol) implementation of reporter. More...

#include "micro-os-plus/micro-test-plus.h"

Inheritance diagram for micro_os_plus::micro_test_plus::reporter_tap:

Public Member Functions

 reporter_tap (const reporter_tap &)=delete
 Deleted copy constructor to prevent copying.
 reporter_tap (reporter_tap &&)=delete
 Deleted move constructor to prevent moving.
 reporter_tap (std::unique_ptr< std::vector< std::string_view > > argvs)
 Constructor for the reporter_tap class.
 ~reporter_tap () override
 Destructor for the reporter_tap class.
void begin_session (runner &runner) override
 Mark the beginning of a test session.
virtual void begin_subtest (subtest &subtest) override
 Mark the beginning of a subtest.
virtual void begin_suite (suite &suite) override
 Mark the beginning of a test suite.
void end_session (runner &runner) override
 Mark the end of a test session.
virtual void end_subtest (subtest &subtest) override
 Mark the end of a subtest.
virtual void end_suite (suite &suite) override
 Mark the end of a test suite.
void endline (void)
 Inserts a line ending into the output buffer.
detail::expression_formatterexpression ()
 Provides access to the expression formatter for this reporter.
void fail (bool abort, std::string &message, const std::string &expression, bool has_expression, const reflection::source_location &location, subtest &subtest)
 Report a failed condition.
void flush (void)
 Flush the current buffered content.
virtual const char * get_comment_prefix (void) override
 Returns the TAP comment prefix string "# ".
reporteroperator<< (bool v)
 Output operator for boolean values.
reporteroperator<< (char c)
 Output operator for a single character.
reporteroperator<< (const char *s)
 Output operator for a constant character string.
reporter_tapoperator<< (detail::indent_t m)
 Output operator for the indent_t manipulator.
reporteroperator<< (reporter &(*func)(reporter &))
 Output operator to display the endl.
reporteroperator<< (std::nullptr_t)
 Output operator for nullptr.
reporteroperator<< (std::string_view sv)
 Output operator for std::string_view.
template<typename T>
reporteroperator<< (T *v)
 Output operator to display any pointer.
template<class T>
requires std::is_arithmetic_v<T>
reporteroperator<< (T v)
 Output operator for arithmetic types, with type suffixes.
reporter_tapoperator= (const reporter_tap &)=delete
 Deleted copy assignment operator to prevent copying.
reporter_tapoperator= (reporter_tap &&)=delete
 Deleted move assignment operator to prevent moving.
void pass (std::string &message, const std::string &expression, subtest &subtest)
 Report a passed condition.
auto verbosity () const -> micro_test_plus::verbosity
 Returns the current verbosity level.
void write_buffer_to_stdout (void)
 Output the current buffered content.

Protected Member Functions

auto colour_ (const bool cond) const
 Selects the appropriate colour code based on a condition.
void output_fail_prefix_ (std::string &message, const bool has_expression, const reflection::source_location &location, subtest &subtest) override
 Outputs the prefix for a failing condition.
void output_fail_suffix_ (const reflection::source_location &location, bool abort, subtest &subtest) override
 Outputs the suffix for a failing condition.
void output_pass_prefix_ (std::string &message, subtest &subtest) override
 Outputs the prefix for a passing condition.
void output_pass_suffix_ (subtest &subtest) override
 Outputs the suffix for a passing condition.
void write_buffer_to_file_ (void)
void write_info_ (void)
 Appends informational (non-result) text to the output buffer.

Protected Attributes

bool add_empty_line_ { true }
 Controls whether to add an empty line between successful test cases.
std::unique_ptr< std::vector< std::string_view > > argvs_ {}
 Owns the command-line arguments passed to the test runner.
std::string buffer_ {}
 Output accumulation buffer.
detail::colours colours_ {}
 ANSI colour codes for output formatting.
detail::expression_formatter expression_ { colours_ }
 Expression formatter for pass and fail reporting.
FILE * output_file_ { nullptr }
 Optional output file for redirecting test report output.
const char * output_file_path_ { nullptr }
 Optional file path for redirecting test report output.
enum verbosity verbosity_ = verbosity::normal
 The verbosity level for test reporting.

Detailed Description

reporter_tap provides a concrete implementation of the reporter abstract interface that formats test results according to the Test Anything Protocol (TAP). It accumulates output in an internal string buffer and writes it to the standard output stream.

Users who require custom output behaviour (e.g. redirecting to a serial port on bare-metal targets) may derive a new class from reporter and supply an instance via the reporter global pointer before calling initialize().

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 102 of file reporter-tap.h.

Constructor & Destructor Documentation

◆ reporter_tap() [1/3]

micro_os_plus::micro_test_plus::reporter_tap::reporter_tap ( std::unique_ptr< std::vector< std::string_view > > argvs)
Parameters
argvsOwning pointer to the command-line arguments vector; the reporter takes ownership via move.

Delegates construction to the reporter base class with the supplied argument vector. If tracing is enabled, the function signature is output for diagnostic purposes.

Definition at line 76 of file reporter-tap.cpp.

78 : reporter{ std::move (argvs) }
79 {
80#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
81 trace::printf ("%s\n", __PRETTY_FUNCTION__);
82#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
83 }
reporter(std::unique_ptr< std::vector< std::string_view > > argvs)
Constructor for the reporter class.
Definition reporter.cpp:80

References micro_os_plus::micro_test_plus::reporter::reporter().

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

◆ reporter_tap() [2/3]

micro_os_plus::micro_test_plus::reporter_tap::reporter_tap ( const reporter_tap & )
delete

References reporter_tap().

◆ reporter_tap() [3/3]

micro_os_plus::micro_test_plus::reporter_tap::reporter_tap ( reporter_tap && )
delete

References reporter_tap().

◆ ~reporter_tap()

micro_os_plus::micro_test_plus::reporter_tap::~reporter_tap ( )
override

No resources are owned directly by reporter_tap; the destructor performs no explicit clean-up. If tracing is enabled, the function signature is output for diagnostic purposes.

Definition at line 91 of file reporter-tap.cpp.

92 {
93#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
94 trace::printf ("%s\n", __PRETTY_FUNCTION__);
95#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
96 }

Member Function Documentation

◆ begin_session()

void micro_os_plus::micro_test_plus::reporter_tap::begin_session ( runner & runner)
overridevirtual
Parameters
runnerReference to the test runner.
Returns
Nothing.

If verbosity is not silent, emits a blank line to stdout and then calls write_info_() to output build and environment information. The TAP version header "TAP version 14" is then written to both the output file (if open) and stdout. The add_empty_line_ flag is cleared so that the first suite header is not separated by an extra blank line.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 128 of file reporter-tap.cpp.

129 {
130#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
131 trace::printf ("%s\n", __PRETTY_FUNCTION__);
132#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
133
135 {
136 printf ("\n");
137 }
138
139 write_info_ ();
140
141 const char* message = "TAP version 14";
142 if (output_file_ != nullptr)
143 {
144 fprintf (output_file_, "%s\n", message);
145 }
146
148 {
149 printf ("%s\n", message);
150
151 flush ();
152 }
153
154 add_empty_line_ = false;
155 }
FILE * output_file_
Optional output file for redirecting test report output.
Definition reporter.h:600
bool add_empty_line_
Controls whether to add an empty line between successful test cases.
Definition reporter.h:581
void write_info_(void)
Appends informational (non-result) text to the output buffer.
Definition reporter.cpp:251
void flush(void)
Flush the current buffered content.
Definition reporter.cpp:348
enum verbosity verbosity_
The verbosity level for test reporting.
Definition reporter.h:546

References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::reporter::verbosity_, and micro_os_plus::micro_test_plus::reporter::write_info_().

◆ begin_subtest()

void micro_os_plus::micro_test_plus::reporter_tap::begin_subtest ( subtest & subtest)
overridevirtual
Parameters
subtestReference to the subtest.
Returns
Nothing.

Validates that the output buffer is empty at subtest start; if not, the buffer is written to stdout, the stream is flushed, and execution is aborted. A "# Subtest: <name>" comment line (indented according to nesting depth) is written to the output file and, under normal or verbose verbosity, to stdout as well.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 404 of file reporter-tap.cpp.

405 {
406#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
407 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, subtest.name ());
408#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
409
410 if (!buffer_.empty ())
411 {
412 // Each suite should start with an empty buffer.
414 flush ();
415 abort ();
416 }
417
418 std::string indent (indent_size * subtest.nesting_depth (), ' ');
419
420 char message_subtest[120];
421 snprintf (message_subtest, sizeof (message_subtest), "%s# Subtest: %s",
422 indent.c_str (), subtest.name ());
423
424 if (output_file_ != nullptr)
425 {
426 fprintf (output_file_, "%s\n", message_subtest);
427 }
428
430 {
431 if (add_empty_line_)
432 {
433 printf ("\n");
434 }
435
436 printf ("%s\n", message_subtest);
437
438 flush ();
439
440 add_empty_line_ = false;
441 }
442 }
void write_buffer_to_stdout(void)
Output the current buffered content.
Definition reporter.cpp:218
std::string buffer_
Output accumulation buffer.
Definition reporter.h:561
constexpr size_t indent_size
Number of spaces per indentation level.
detail::indent_t indent(size_t level)
Factory function that creates an indent_t manipulator.

References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::indent(), micro_os_plus::micro_test_plus::indent_size, micro_os_plus::micro_test_plus::detail::test_node::name(), micro_os_plus::micro_test_plus::subtest::nesting_depth(), micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::verbose, micro_os_plus::micro_test_plus::reporter::verbosity_, and micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout().

◆ begin_suite()

void micro_os_plus::micro_test_plus::reporter_tap::begin_suite ( suite & suite)
overridevirtual
Parameters
suiteReference to the test suite.
Returns
Nothing.

Emits a "# Subtest: <name>" comment line to mark the start of a TAP subtest block for the suite. The line is written to the output file when one is open. Under normal or verbose verbosity, it is also written to stdout, preceded by a blank line when add_empty_line_ is set.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 246 of file reporter-tap.cpp.

247 {
248#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
249 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
250#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
251
252 char message_subtest[120];
253 snprintf (message_subtest, sizeof (message_subtest), "# Subtest: %s",
254 suite.name ());
255
256 if (output_file_ != nullptr)
257 {
258 fprintf (output_file_, "%s\n", message_subtest);
259 }
260
262 {
263 if (add_empty_line_)
264 {
265 printf ("\n");
266 }
267
268 printf ("%s\n", message_subtest);
269
270 flush ();
271
272 add_empty_line_ = true;
273 }
274 }

References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::detail::test_node::name(), micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::verbose, and micro_os_plus::micro_test_plus::reporter::verbosity_.

◆ colour_()

auto micro_os_plus::micro_test_plus::reporter::colour_ ( const bool cond) const
inlinenodiscardprotectedinherited
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 119 of file reporter-inlines.h.

120 {
121 return cond ? colours_.pass : colours_.fail;
122 }
detail::colours colours_
ANSI colour codes for output formatting.
Definition reporter.h:551

References colours_.

Referenced by get_comment_prefix().

◆ end_session()

void micro_os_plus::micro_test_plus::reporter_tap::end_session ( runner & runner)
overridevirtual
Parameters
runnerReference to the test runner.
Returns
Nothing.

Emits the TAP plan line (1..N, where N is the total number of test suites) followed by a comment line summarising successful checks, failed checks, executed test cases, elapsed time, and suite count. Both lines are written to the output file when one is open. When verbosity is set to quiet, the plan is replaced by 1..0 to produce a valid skipped-test TAP document.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 167 of file reporter-tap.cpp.

168 {
169#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
170 trace::printf ("%s\n", __PRETTY_FUNCTION__);
171#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
172
173 size_t total_suites_count = runner.total_suites_count ();
174
175 uint32_t milliseconds = 0;
176 uint32_t microseconds = 0;
177 if (runner.timings ().has_timestamps ())
178 {
179 runner.timings ().compute_elapsed_time (milliseconds, microseconds);
180 }
181
182 char message_summary[32];
183 snprintf (message_summary, sizeof (message_summary), "1..%zu",
184 total_suites_count);
185
186 char message_totals[160];
187 snprintf (message_totals, sizeof (message_totals),
188 "total: %zu check%s passed, %zu failed, in %zu test "
189 "case%s, %zu test suite%s",
190 runner.totals ().successful_checks (),
191 runner.totals ().successful_checks () == 1 ? "" : "s",
192 runner.totals ().failed_checks (),
193 runner.totals ().executed_subtests (),
194 runner.totals ().executed_subtests () == 1 ? "" : "s",
195 total_suites_count, total_suites_count == 1 ? "" : "s");
196
197 char message_time[120] = "";
198 if (milliseconds > 0 || microseconds > 0)
199 {
200 snprintf (message_time, sizeof (message_time),
201 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
202 microseconds);
203 }
204
205 if (output_file_ != nullptr)
206 {
207 fprintf (output_file_, "%s\n# { %s%s }\n", message_summary,
208 message_totals, message_time);
209 }
210
212 {
213 if (add_empty_line_)
214 {
215 printf ("\n");
216 }
217
219 {
220 printf ("%s\n", message_summary);
221 }
222 else
223 {
224 // With quiet verbosity, there are no ok/not ok lines, so the TAP
225 // plan should look like a skipped test.
226 printf ("1..0\n");
227 }
228
229 printf ("# { %s%s }\n", message_totals, message_time);
230
231 flush ();
232 }
233 }

References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::timestamps::compute_elapsed_time(), micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests(), micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks(), micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::detail::timestamps::has_timestamps(), micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::quiet, micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks(), micro_os_plus::micro_test_plus::runner::timings(), micro_os_plus::micro_test_plus::runner::total_suites_count(), micro_os_plus::micro_test_plus::detail::test_node::totals(), and micro_os_plus::micro_test_plus::reporter::verbosity_.

◆ end_subtest()

void micro_os_plus::micro_test_plus::reporter_tap::end_subtest ( subtest & subtest)
overridevirtual
Parameters
subtestReference to the subtest.
Returns
Nothing.

Emits the TAP plan line for the subtest's checks followed by an ok/not ok result line that includes the subtest index, name, pass/fail status, and check counts. Any output accumulated in buffer_ is flushed to the output file and, when verbosity is verbose or the subtest failed, to stdout as well. The buffer is cleared on exit.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 454 of file reporter-tap.cpp.

455 {
456#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
457 trace::printf ("%s '%s' i%zu +%zu -%zu in xc%zu, xs%zu | cs%zu\n",
458 __PRETTY_FUNCTION__, subtest.name (),
459 subtest.nesting_depth (),
460 subtest.totals ().successful_checks (),
461 subtest.totals ().failed_checks (),
462 subtest.totals ().executed_checks (),
463 subtest.totals ().executed_subtests (),
464 subtest.children_subtests_count ());
465#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
466
467 std::string indent (indent_size * subtest.nesting_depth (), ' ');
468 std::string indent2 (indent_size * (subtest.nesting_depth () + 1), ' ');
469
470 char message_summary[40];
471 snprintf (message_summary, sizeof (message_summary), "%s1..%zu",
472 indent2.c_str (),
473 subtest.totals ().executed_checks ()
474 + subtest.totals ().executed_subtests ());
475
476 char message_totals[120];
477 if (subtest.totals ().was_successful ()) [[likely]]
478 {
479 snprintf (message_totals, sizeof (message_totals),
480 "%sok %zu - %s # { passed, %zu check%s }", indent.c_str (),
481 subtest.own_index (), subtest.name (),
482 subtest.totals ().successful_checks (),
483 subtest.totals ().successful_checks () == 1 ? "" : "s");
484 }
485 else
486 {
487 snprintf (message_totals, sizeof (message_totals),
488 "%snot ok %zu - %s # { FAILED, %zu check%s "
489 "passed, %zu failed }",
490 indent.c_str (), subtest.own_index (), subtest.name (),
491 subtest.totals ().successful_checks (),
492 subtest.totals ().successful_checks () == 1 ? "" : "s",
493 subtest.totals ().failed_checks ());
494 }
495
496 if (output_file_ != nullptr)
497 {
499
500 fprintf (output_file_, "%s\n%s\n", message_summary, message_totals);
501 }
502
503 // At this point, the buffer may contain output from the subtest, which
504 // should be displayed.
506 {
507 if (add_empty_line_)
508 {
509 printf ("\n");
510 }
511
512 if (subtest.totals ().was_successful ()) [[likely]]
513 {
514 // Successful subtest.
516 {
517 // With verbosity, show full TAP output accumulated in the
518 // buffer.
520
521 printf ("%s\n", message_summary);
522 }
523 else
524 {
525 // Without verbosity, show only the summary line
526 // and count only subtests, not checks, as the TAP output is
527 // not shown.
528 printf ("%s1..%zu\n", indent2.c_str (),
529 subtest.totals ().executed_subtests ());
530 }
531
532 printf ("%s\n", message_totals);
533 }
534 else
535 {
536 // Failed subtest.
537
538 // Show full TAP output accumulated in the buffer for failed
539 // subtests, as it may contain useful information about the
540 // failure.
542
543 printf ("%s\n%s\n", message_summary, message_totals);
544 }
545
546 flush ();
547 }
548
549 buffer_.clear ();
550
551 add_empty_line_ = true;
552 }

References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::detail::runnable_base::children_subtests_count(), micro_os_plus::micro_test_plus::detail::runner_totals::executed_checks(), micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests(), micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks(), micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::indent(), micro_os_plus::micro_test_plus::indent_size, micro_os_plus::micro_test_plus::detail::test_node::name(), micro_os_plus::micro_test_plus::subtest::nesting_depth(), micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::detail::runnable_base::own_index(), micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks(), micro_os_plus::micro_test_plus::detail::test_node::totals(), micro_os_plus::micro_test_plus::verbose, micro_os_plus::micro_test_plus::reporter::verbosity_, micro_os_plus::micro_test_plus::detail::runner_totals::was_successful(), micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_(), and micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout().

◆ end_suite()

void micro_os_plus::micro_test_plus::reporter_tap::end_suite ( suite & suite)
overridevirtual
Parameters
suiteReference to the test suite.
Returns
Nothing.

Emits the TAP plan line for the suite's subtests followed by an ok/not ok result line that includes the suite index, name, pass/fail status, check counts, subtest count, and elapsed time. Any output accumulated in buffer_ is flushed to the output file and, when verbosity is verbose or the suite failed, to stdout as well. The buffer is cleared on exit.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 286 of file reporter-tap.cpp.

287 {
288#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
289 trace::printf (
290 "%s '%s' +%zu -%zu in xc%zu, xs%zu | cs%zu\n", __PRETTY_FUNCTION__,
291 suite.name (), suite.totals ().successful_checks (),
292 suite.totals ().failed_checks (), suite.totals ().executed_checks (),
293 suite.totals ().executed_subtests (),
294 suite.children_subtests_count ());
295#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
296
297 uint32_t milliseconds = 0;
298 uint32_t microseconds = 0;
299 if (suite.timings ().has_timestamps ())
300 {
301 suite.timings ().compute_elapsed_time (milliseconds, microseconds);
302 }
303
304 std::string indent (indent_size, ' ');
305
306 char message_summary[40];
307 snprintf (message_summary, sizeof (message_summary), "%s1..%zu",
308 indent.c_str (), suite.children_subtests_count ());
309 char message_totals[120];
310 if (suite.totals ().was_successful ()) [[likely]]
311 {
312 snprintf (message_totals, sizeof (message_totals),
313 "ok %zu - %s # { passed, %zu check%s in %zu "
314 "test case%s",
315 suite.own_index (), suite.name (),
316 suite.totals ().successful_checks (),
317 suite.totals ().successful_checks () == 1 ? "" : "s",
318 suite.totals ().executed_subtests (),
319 suite.totals ().executed_subtests () == 1 ? "" : "s");
320 }
321 else
322 {
323 snprintf (message_totals, sizeof (message_totals),
324 "not ok %zu - %s # { FAILED, %zu check%s "
325 "passed, %zu failed, in %zu test case%s",
326 suite.own_index (), suite.name (),
327 suite.totals ().successful_checks (),
328 suite.totals ().successful_checks () == 1 ? "" : "s",
329 suite.totals ().failed_checks (),
330 suite.totals ().executed_subtests (),
331 suite.totals ().executed_subtests () == 1 ? "" : "s");
332 }
333
334 char message_time[120] = "";
335 if (milliseconds > 0 || microseconds > 0)
336 {
337 snprintf (message_time, sizeof (message_time),
338 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
339 microseconds);
340 }
341
342 if (output_file_ != nullptr)
343 {
345
346 fprintf (output_file_, "%s\n%s%s }\n", message_summary, message_totals,
347 message_time);
348 }
349
350 // At this point, the buffer may contain output from the test case, which
351 // should be displayed.
353 {
354 if (add_empty_line_ && suite.totals ().executed_subtests () > 0)
355 {
356 printf ("\n");
357 }
358
359 if (suite.totals ().was_successful ()) [[likely]]
360 {
361 // Successful test suite.
362
364 {
365 // With verbosity, show full TAP output accumulated in the
366 // buffer.
368 }
369
370 printf ("%s\n%s%s }\n", message_summary, message_totals,
371 message_time);
372 }
373 else
374 {
375 // Failed test suite.
376
377 // Show full TAP output accumulated in the buffer for failed suite
378 // cases, as it may contain useful information about the failure.
380
381 printf ("%s\n%s%s }\n", message_summary, message_totals,
382 message_time);
383 }
384
385 flush ();
386 }
387
388 buffer_.clear ();
389
390 add_empty_line_ = true;
391 }

References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::detail::runnable_base::children_subtests_count(), micro_os_plus::micro_test_plus::detail::timestamps::compute_elapsed_time(), micro_os_plus::micro_test_plus::detail::runner_totals::executed_checks(), micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests(), micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks(), micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::detail::timestamps::has_timestamps(), micro_os_plus::micro_test_plus::indent(), micro_os_plus::micro_test_plus::indent_size, micro_os_plus::micro_test_plus::detail::test_node::name(), micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::detail::runnable_base::own_index(), micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks(), micro_os_plus::micro_test_plus::suite::timings(), micro_os_plus::micro_test_plus::detail::test_node::totals(), micro_os_plus::micro_test_plus::verbose, micro_os_plus::micro_test_plus::reporter::verbosity_, micro_os_plus::micro_test_plus::detail::runner_totals::was_successful(), micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_(), and micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout().

◆ endline()

void micro_os_plus::micro_test_plus::reporter::endline ( void )
inherited
Parameters
None.
Returns
Nothing.

This method appends a newline character to the internal output buffer of the 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.

Definition at line 202 of file reporter.cpp.

203 {
204 buffer_.append ("\n");
205 flush ();
206 }

References buffer_, and flush().

Referenced by micro_os_plus::micro_test_plus::endl().

◆ expression()

detail::expression_formatter & micro_os_plus::micro_test_plus::reporter::expression ( )
inlineinherited
Parameters
None.
Returns
Reference to the expression_formatter instance used by this reporter.

Returns a reference to the expression_formatter instance used by the reporter for formatting expressions in test reports. This allows the reporter to delegate the formatting of complex expressions to the expression_formatter, which provides a consistent and extensible way to convert various types of values and expressions into their string representations for output in test reports.

Definition at line 108 of file reporter-inlines.h.

109 {
110 return expression_;
111 }
detail::expression_formatter expression_
Expression formatter for pass and fail reporting.
Definition reporter.h:572

References expression_.

Referenced by micro_os_plus::micro_test_plus::subtest::assume(), micro_os_plus::micro_test_plus::subtest::expect(), fail(), get_comment_prefix(), operator<<(), and pass().

◆ fail()

void micro_os_plus::micro_test_plus::reporter::fail ( bool abort,
std::string & message,
const std::string & expression,
bool has_expression,
const reflection::source_location & location,
subtest & subtest )
inherited
Parameters
abortWhether to abort execution after failure.
messageThe message to display.
expressionThe string representation of the expression.
has_expressionWhether the expression is a compound op to display.
locationThe source location of the failure.
subtestThe subtest that owns this check.
Returns
Nothing.

Reports a test failure, formatting the output with source location and, when has_expression is true, the pre-formatted expression string.

Definition at line 446 of file reporter.cpp.

450 {
451 output_fail_prefix_ (message, has_expression, location, subtest);
452
453 if (has_expression)
454 {
455 *this << expression;
456 }
457
458 output_fail_suffix_ (location, abort, subtest);
459 }
virtual void output_fail_prefix_(std::string &message, const bool has_expression, const reflection::source_location &location, subtest &subtest)=0
Outputs the prefix for a failing condition.
detail::expression_formatter & expression()
Provides access to the expression formatter for this reporter.
virtual void output_fail_suffix_(const reflection::source_location &location, bool abort, subtest &subtest)=0
Outputs the suffix for a failing condition.

References expression(), output_fail_prefix_(), and output_fail_suffix_().

◆ flush()

void micro_os_plus::micro_test_plus::reporter::flush ( void )
inherited
Parameters
None.
Returns
Nothing.

This method flushes the output buffer of the 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.

Definition at line 348 of file reporter.cpp.

349 {
350 fflush (stdout);
351 if (output_file_ != nullptr)
352 {
353 fflush (output_file_);
354 }
355 }

References output_file_.

Referenced by micro_os_plus::micro_test_plus::reporter_human::begin_session(), micro_os_plus::micro_test_plus::reporter_tap::begin_session(), micro_os_plus::micro_test_plus::reporter_human::begin_subtest(), micro_os_plus::micro_test_plus::reporter_tap::begin_subtest(), micro_os_plus::micro_test_plus::reporter_human::begin_suite(), micro_os_plus::micro_test_plus::reporter_tap::begin_suite(), micro_os_plus::micro_test_plus::reporter_human::end_session(), micro_os_plus::micro_test_plus::reporter_tap::end_session(), micro_os_plus::micro_test_plus::reporter_human::end_subtest(), micro_os_plus::micro_test_plus::reporter_tap::end_subtest(), micro_os_plus::micro_test_plus::reporter_human::end_suite(), micro_os_plus::micro_test_plus::reporter_tap::end_suite(), endline(), micro_os_plus::micro_test_plus::reporter_human::output_fail_suffix_(), micro_os_plus::micro_test_plus::reporter_tap::output_fail_suffix_(), micro_os_plus::micro_test_plus::reporter_human::output_pass_suffix_(), and micro_os_plus::micro_test_plus::reporter_tap::output_pass_suffix_().

◆ get_comment_prefix()

const char * micro_os_plus::micro_test_plus::reporter_tap::get_comment_prefix ( void )
overridevirtual
Parameters
None.
Returns
The string "# ", used to prefix comment lines in TAP output.

Returns "# ". The TAP reporter prefixes all comment lines, including the informational lines emitted by write_info_(), with the TAP comment marker.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 563 of file reporter-tap.cpp.

564 {
565 return "# ";
566 }

◆ operator<<() [1/9]

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

◆ operator<<() [2/9]

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

This operator overload appends the specified character to the internal output buffer of the 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 225 of file reporter.cpp.

400 {
401 buffer_.append (1, c);
402 return *this;
403 }

◆ operator<<() [3/9]

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

This operator overload appends the contents of the provided C-style string to the internal output buffer of the 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 234 of file reporter.cpp.

415 {
416 buffer_.append (s);
417 return *this;
418 }

◆ operator<<() [4/9]

reporter_tap & micro_os_plus::micro_test_plus::reporter_tap::operator<< ( detail::indent_t m)
Parameters
mThe indentation manipulator produced by indent(n).
Returns
Reference to the current reporter instance.

This operator overload appends spaces to the internal output buffer corresponding to m.level four-space indentation levels. It enables structured, readable nesting of suite output across all test cases and folders by allowing *this << indent(n) << "text" chaining.

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

111 {
112 buffer_.append (m.level * indent_size, ' ');
113 return *this;
114 }

References reporter_tap(), micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::indent_size, and micro_os_plus::micro_test_plus::detail::indent_t::level.

◆ operator<<() [5/9]

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

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

Definition at line 283 of file reporter.cpp.

370 {
371 // Call the endl function.
372 (*func) (*this);
373 return *this;
374 }

◆ operator<<() [6/9]

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

◆ operator<<() [7/9]

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

This operator overload appends the contents of the provided std::string_view to the internal output buffer of the 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 216 of file reporter.cpp.

386 {
387 buffer_.append (sv);
388 return *this;
389 }

◆ operator<<() [8/9]

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

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

Null pointers are always rendered as the string "nullptr", regardless of the platform, avoiding platform-specific behaviour such as "(nil)" on Linux/glibc or "0x0" on macOS.

Non-null pointers are formatted as a hexadecimal address using snprintf with the p format specifier. 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 274 of file reporter-inlines.h.

147 {
148 if (v == nullptr)
149 {
150 // Explicitly render null pointers as "0x0" to avoid platform-specific
151 // representations such as "(nil)" on Linux/glibc.
152 buffer_.append ("0x0");
153 return *this;
154 }
155
156#if defined(__GNUC__)
157#pragma GCC diagnostic push
158
159#if defined(__clang__)
160#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
161#endif // defined(__clang__)
162#endif // defined(__GNUC__)
163
164 char buff[20];
165 snprintf (buff, sizeof (buff), "%p", reinterpret_cast<void*> (v));
166 buffer_.append (buff);
167
168#if defined(__GNUC__)
169#pragma GCC diagnostic pop
170#endif // defined(__GNUC__)
171
172 return *this;
173 }

◆ operator<<() [9/9]

template<class T>
requires std::is_arithmetic_v<T>
reporter & micro_os_plus::micro_test_plus::reporter::operator<< ( T v)
Template Parameters
TThe arithmetic type.
Parameters
vThe value to output.
Returns
Reference to the current reporter instance.

This template operator overload allows the reporter to output values of any arithmetic type (integral or floating-point) in a consistent and readable format. The value is formatted using the append_number_ helper function, which handles the conversion to a string representation with appropriate type suffixes where applicable (e.g., "f" for float, "l" for long double). This enables numeric values to be included in test reports and diagnostics in a clear and unambiguous manner, supporting the verification of test cases that involve arithmetic expressions and comparisons.

Definition at line 262 of file reporter-inlines.h.

191 {
193 return *this;
194 }
void append_number_(std::string &buffer, T v)
Appends the string representation of a numeric value to a buffer, using std::to_chars for allocation-...

◆ operator=() [1/2]

reporter_tap & micro_os_plus::micro_test_plus::reporter_tap::operator= ( const reporter_tap & )
delete

References reporter_tap().

◆ operator=() [2/2]

reporter_tap & micro_os_plus::micro_test_plus::reporter_tap::operator= ( reporter_tap && )
delete

References reporter_tap().

◆ output_fail_prefix_()

void micro_os_plus::micro_test_plus::reporter_tap::output_fail_prefix_ ( std::string & message,
const bool has_expression,
const reflection::source_location & location,
subtest & subtest )
overrideprotectedvirtual
Parameters
messageThe message to display.
has_expressionWhether the failure is associated with an expression.
locationThe source location of the failure.
subtestThe subtest that owns this check.
Returns
Nothing.

This method outputs the prefix for a failing check result, applying the appropriate colour formatting and symbols to clearly indicate failure. If the output occurs within a subtest, additional indentation is applied for readability. The prefix includes a cross symbol (), an optional message, and YAML diagnostics preamble. Colour formatting and line structure are arranged to conform to TAP14 diagnostics output.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 618 of file reporter-tap.cpp.

622 {
623 size_t level = subtest.nesting_depth ();
624 *this << indent (level + 1) << "not ok "
625 << static_cast<int> (subtest.current_subtest_index ());
626
627 if (!message.empty ())
628 {
629 *this << " - " << message.c_str ();
630 }
631 *this << endl;
632
633 // https://testanything.org/tap-version-14-specification.html
634 // 2-space indentation for YAML diagnostics.
635 *this << indent (level + 1) << " ---";
636 if (has_expression)
637 {
638 *this << endl;
639 *this << indent (level + 1) << " condition: ";
640 }
641 }
reporter & endl(reporter &stream)
Output stream manipulator for ending a line in test reports.
Definition reporter.cpp:187

References micro_os_plus::micro_test_plus::detail::runnable_base::current_subtest_index(), micro_os_plus::micro_test_plus::endl(), micro_os_plus::micro_test_plus::indent(), and micro_os_plus::micro_test_plus::subtest::nesting_depth().

◆ output_fail_suffix_()

void micro_os_plus::micro_test_plus::reporter_tap::output_fail_suffix_ ( const reflection::source_location & location,
bool abort,
subtest & subtest )
overrideprotectedvirtual
Parameters
locationThe source location of the failure.
abortWhether to abort execution after failure.
subtestThe subtest that owns this check.
Returns
Nothing.

Completes TAP14 YAML diagnostics for a failing check, optionally appends an "aborted..." marker, emits source filename/line fields, closes the YAML block, and flushes the stream.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 650 of file reporter-tap.cpp.

653 {
654 size_t level = subtest.nesting_depth ();
655 if (abort)
656 {
657 *this << " aborted...";
658 }
659 *this << endl;
660
661 // https://testanything.org/tap-version-14-specification.html
662 // 2-space indentation for YAML diagnostics.
663
664 *this << indent (level + 1) << " at:" << endl;
665 *this << indent (level + 1)
666 << " filename: " << reflection::short_name (location.file_name ())
667 << endl;
668 *this << indent (level + 1) << " line: " << location.line () << endl;
669
670 *this << indent (level + 1) << " ..." << endl;
671
672 flush ();
673 }
const char * short_name(const char *name) noexcept
Extract a short type or function name from a fully qualified name.

References micro_os_plus::micro_test_plus::endl(), micro_os_plus::micro_test_plus::reflection::source_location::file_name(), micro_os_plus::micro_test_plus::reporter::flush(), micro_os_plus::micro_test_plus::indent(), micro_os_plus::micro_test_plus::reflection::source_location::line(), micro_os_plus::micro_test_plus::subtest::nesting_depth(), and micro_os_plus::micro_test_plus::reflection::short_name().

◆ output_pass_prefix_()

void micro_os_plus::micro_test_plus::reporter_tap::output_pass_prefix_ ( std::string & message,
subtest & subtest )
overrideprotectedvirtual
Parameters
messageThe message to display.
subtestThe subtest that owns this check.
Returns
Nothing.

This method outputs the prefix for a passing check result, applying the appropriate colour formatting and symbols to clearly indicate success. If the output occurs within a subtest, 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.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 581 of file reporter-tap.cpp.

582 {
583 size_t level = subtest.nesting_depth ();
584 *this << indent (level + 1) << "ok "
585 << static_cast<int> (subtest.current_subtest_index ()) << " - ";
586 if (!message.empty ())
587 {
588 *this << message.c_str ();
589 }
590 }

References micro_os_plus::micro_test_plus::detail::runnable_base::current_subtest_index(), micro_os_plus::micro_test_plus::indent(), and micro_os_plus::micro_test_plus::subtest::nesting_depth().

◆ output_pass_suffix_()

void micro_os_plus::micro_test_plus::reporter_tap::output_pass_suffix_ ( subtest & subtest)
overrideprotectedvirtual
Parameters
subtestThe subtest that owns this check.
Returns
Nothing.

Completes pass output by appending endl and flushing buffered content to the configured sinks.

The prefix/suffix methods help shorten the code generated by the template methods.

Implements micro_os_plus::micro_test_plus::reporter.

Definition at line 601 of file reporter-tap.cpp.

602 {
603 *this << endl;
604
605 flush ();
606 }

References micro_os_plus::micro_test_plus::endl(), and micro_os_plus::micro_test_plus::reporter::flush().

◆ pass()

void micro_os_plus::micro_test_plus::reporter::pass ( std::string & message,
const std::string & expression,
subtest & subtest )
inherited
Parameters
messageThe message to display.
expressionThe string representation of the expression.
subtestThe subtest that owns this check.
Returns
Nothing.

Outputs a pass prefix, followed by either the provided message or, if the message is empty, the evaluated expression string itself. A pass suffix is then appended to complete the output.

Definition at line 427 of file reporter.cpp.

429 {
430 output_pass_prefix_ (message, subtest);
431
432 if (message.empty ())
433 {
434 *this << expression;
435 }
436
437 output_pass_suffix_ (subtest);
438 }
virtual void output_pass_suffix_(subtest &subtest)=0
Outputs the suffix for a passing condition.
virtual void output_pass_prefix_(std::string &message, subtest &subtest)=0
Outputs the prefix for a passing condition.

References expression(), output_pass_prefix_(), and output_pass_suffix_().

◆ verbosity()

auto micro_os_plus::micro_test_plus::reporter::verbosity ( ) const -> micro_test_plus::verbosity
inlineinherited
Parameters
None.
Returns
The active verbosity value.

Returns the verbosity level stored in verbosity_.

Definition at line 93 of file reporter-inlines.h.

94 {
95 return verbosity_;
96 }

References verbosity(), and verbosity_.

Referenced by get_comment_prefix(), and verbosity().

◆ write_buffer_to_file_()

void micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_ ( void )
protectedinherited

Writes the contents of buffer_ to output_file_ using fprintf without appending a newline. If output_file_ is null, the call is a no-op.

Definition at line 231 of file reporter.cpp.

232 {
233 // Pass only the string, do not add an `\n` here.
234 if (output_file_ != nullptr)
235 {
236 fprintf (output_file_, "%s", buffer_.c_str ());
237 }
238 }

Referenced by micro_os_plus::micro_test_plus::reporter_human::end_subtest(), micro_os_plus::micro_test_plus::reporter_tap::end_subtest(), micro_os_plus::micro_test_plus::reporter_human::end_suite(), micro_os_plus::micro_test_plus::reporter_tap::end_suite(), and get_comment_prefix().

◆ write_buffer_to_stdout()

void micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout ( void )
inherited
Note
Public because deferred_reporter_base calls this from its destructor when aborting, after the subtest instance is no longer accessible via the normal reporting path.
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.

Definition at line 218 of file reporter.cpp.

219 {
220 // Pass only the string, do not add an `\n` here.
221 printf ("%s", buffer_.c_str ());
222 }

References buffer_.

Referenced by micro_os_plus::micro_test_plus::reporter_tap::begin_subtest(), micro_os_plus::micro_test_plus::reporter_human::end_subtest(), micro_os_plus::micro_test_plus::reporter_tap::end_subtest(), micro_os_plus::micro_test_plus::reporter_human::end_suite(), and micro_os_plus::micro_test_plus::reporter_tap::end_suite().

◆ write_info_()

void micro_os_plus::micro_test_plus::reporter::write_info_ ( void )
protectedinherited
Parameters
None.
Returns
Nothing.

Constructs and emits two informational lines: the first lists the programme name and any command-line arguments; the second identifies the compiler (Clang, GCC, or MSVC) together with the version string, floating-point availability on bare-metal targets, exception support, and any active debug or trace macros. Both lines are written to the output file when one is open, and to stdout unless verbosity is set to silent.

Definition at line 251 of file reporter.cpp.

252 {
253 if (argvs_ && !argvs_->empty ())
254 {
255 const auto& args = *argvs_;
256 std::string line;
257 line.reserve (256);
258 line.append (get_comment_prefix ());
259 line.append ("Running: ");
260
261 // Append only the file name part of argv[0].
262 const std::string_view arg0 = args[0];
263 const auto sep = arg0.rfind ('/');
264 line.append ((sep != std::string_view::npos) ? arg0.substr (sep + 1)
265 : arg0);
266
267 for (size_t i = 1; i < args.size (); ++i)
268 {
269 line.append (" ");
270 line.append (args[i]);
271 }
272 line.append ("\n");
273
274 if (output_file_ != nullptr)
275 fprintf (output_file_, "%s", line.c_str ());
276
277#if !(defined(MICRO_OS_PLUS_STARTUP_ENABLED) \
278 && defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED))
281 printf ("%s", line.c_str ());
282#endif // !defined(MICRO_OS_PLUS_STARTUP_ENABLED)
283 }
284
285 {
286 // Build the "Built with ..." line. For the output file the compiler
287 // version is omitted; for stdout it is appended via __VERSION__.
288 std::string line;
289 line.reserve (256);
290 line.append (get_comment_prefix ());
291 line.append ("Built with ");
292#if defined(__clang__)
293 line.append ("clang " __VERSION__);
294#elif defined(__GNUC__)
295 line.append ("GCC " __VERSION__);
296#elif defined(_MSC_VER)
297 line.append ("MSVC");
298 char msvc_ver[16];
299 snprintf (msvc_ver, sizeof (msvc_ver), " - %d", _MSC_VER);
300 line.append (msvc_ver);
301#else
302 line.append ("an unknown compiler");
303#endif // defined(__clang__)
304#if !(defined(__APPLE__) || defined(__linux__) || defined(__unix__) \
305 || defined(WIN32))
306 // This is relevant only on bare-metal.
307#if defined(__ARM_PCS_VFP) || defined(__ARM_FP)
308 line.append (", with FP");
309#else
310 line.append (", no FP");
311#endif // defined(__ARM_PCS_VFP) || defined(__ARM_FP)
312#endif // !(defined(__APPLE__) || defined(__linux__) || defined(__unix__) || defined(WIN32))
313#if defined(__EXCEPTIONS)
314 line.append (", with exceptions");
315#else
316 line.append (", no exceptions");
317#endif // defined(__EXCEPTIONS)
318#if defined(MICRO_OS_PLUS_DEBUG_ENABLED)
319 line.append (", with MICRO_OS_PLUS_DEBUG_ENABLED");
320#endif // defined(MICRO_OS_PLUS_DEBUG_ENABLED)
321#if defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
322 line.append (", with MICRO_OS_PLUS_DIAG_TRACE_ENABLED");
323#endif // defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
324
325 if (output_file_ != nullptr)
326 {
327 fprintf (output_file_, "%s\n", line.c_str ());
328 }
329
330#if !(defined(MICRO_OS_PLUS_STARTUP_ENABLED) \
331 && defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED))
333 {
334 printf ("%s\n", line.c_str ());
335 }
336#endif // !defined(MICRO_OS_PLUS_STARTUP_ENABLED)
337 }
338 }
std::unique_ptr< std::vector< std::string_view > > argvs_
Owns the command-line arguments passed to the test runner.
Definition reporter.h:605
virtual const char * get_comment_prefix(void)=0
Returns the comment-prefix string used by this reporter format.

References argvs_, get_comment_prefix(), micro_os_plus::micro_test_plus::normal, output_file_, micro_os_plus::micro_test_plus::verbose, and verbosity_.

Referenced by micro_os_plus::micro_test_plus::reporter_human::begin_session(), micro_os_plus::micro_test_plus::reporter_tap::begin_session(), and get_comment_prefix().

Member Data Documentation

◆ add_empty_line_

◆ argvs_

std::unique_ptr<std::vector<std::string_view> > micro_os_plus::micro_test_plus::reporter::argvs_ {}
protectedinherited

Definition at line 605 of file reporter.h.

605{};

Referenced by reporter(), and write_info_().

◆ buffer_

◆ colours_

◆ expression_

detail::expression_formatter micro_os_plus::micro_test_plus::reporter::expression_ { colours_ }
protectedinherited

Used in pass() and fail() to format expression values before appending the result to buffer_. Will also be used by detail::deferred_reporter to pre-format expressions at construction time.

Definition at line 572 of file reporter.h.

572{ colours_ };

Referenced by expression().

◆ output_file_

◆ output_file_path_

const char* micro_os_plus::micro_test_plus::reporter::output_file_path_ { nullptr }
protectedinherited

When non-null, write_buffer_to_file_() writes accumulated output to this path in addition to (or instead of) standard output.

Definition at line 590 of file reporter.h.

590{ nullptr };

Referenced by reporter(), and ~reporter().

◆ verbosity_


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