C++ source file with implementations for the µTest++ TAP suite reporter methods. More...
Namespaces Index
Description
C++ source file with implementations for the µTest++ TAP suite reporter methods.
This source file contains the implementations for reporter_tap, a concrete implementation of the reporter abstract interface that formats suite results according to the Test Anything Protocol (TAP).
All definitions reside within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.
This file must be included when building the µTest++ library.
File Listing
The file content with the documentation metadata removed is:
37#if __has_include(<micro-os-plus/project-config.h>)
38#include <micro-os-plus/project-config.h>
39#elif __has_include(<micro-os-plus/config.h>)
41 "micro-os-plus/config.h is deprecated, rename to micro-os-plus/project-config.h and include it instead of micro-os-plus/config.h"
42#include <micro-os-plus/config.h>
45#if __has_include(<micro-os-plus/micro-test-plus-defines.h>)
46#include <micro-os-plus/micro-test-plus-defines.h>
49#include <micro-os-plus/diag/trace.h>
61#pragma GCC diagnostic ignored "-Waggregate-return"
63#pragma clang diagnostic ignored "-Wunknown-warning-option"
64#pragma clang diagnostic ignored "-Wc++98-compat"
65#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
82 std::unique_ptr<std::vector<std::string_view>> argvs)
85#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
86 trace::printf ("%s\n", __PRETTY_FUNCTION__);
98#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
99 trace::printf ("%s\n", __PRETTY_FUNCTION__);
135#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
136 trace::printf ("%s\n", __PRETTY_FUNCTION__);
140#pragma GCC diagnostic push
141#if defined(__clang__)
142#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
153 const char* message = "TAP version 14";
161 printf ("%s\n", message);
169#pragma GCC diagnostic pop
185#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
186 trace::printf ("%s\n", __PRETTY_FUNCTION__);
190#pragma GCC diagnostic push
191#if defined(__clang__)
192#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
198 uint32_t milliseconds = 0;
199 uint32_t microseconds = 0;
205 char message_summary[32];
206 snprintf (message_summary, sizeof (message_summary), "1..%zu",
209 char message_totals[160];
210 snprintf (message_totals, sizeof (message_totals),
211 "total: %zu check%s passed, %zu failed, in %zu test "
212 "case%s, %zu test suite%s",
218 total_suites_count, total_suites_count == 1 ? "" : "s");
220 char message_time[120] = "";
221 if (milliseconds > 0 || microseconds > 0)
223 snprintf (message_time, sizeof (message_time),
224 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
230 fprintf (output_file_, "%s\n# { %s%s }\n", message_summary,
231 message_totals, message_time);
243 printf ("%s\n", message_summary);
252 printf ("# { %s%s }\n", message_totals, message_time);
258#pragma GCC diagnostic pop
275#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
276#pragma GCC diagnostic push
277#if defined(__clang__)
278#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
280 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
281#pragma GCC diagnostic pop
285#pragma GCC diagnostic push
286#if defined(__clang__)
287#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
291 char message_subtest[120];
292 snprintf (message_subtest, sizeof (message_subtest), "# Subtest: %s",
307 printf ("%s\n", message_subtest);
315#pragma GCC diagnostic pop
331#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
332#pragma GCC diagnostic push
333#if defined(__clang__)
334#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
337 "%s '%s' +%zu -%zu in xc%zu, xs%zu | cs%zu\n", __PRETTY_FUNCTION__,
343#pragma GCC diagnostic pop
347#pragma GCC diagnostic push
348#if defined(__clang__)
349#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
353 uint32_t milliseconds = 0;
354 uint32_t microseconds = 0;
362 char message_summary[40];
363 snprintf (message_summary, sizeof (message_summary), "%s1..%zu",
365 char message_totals[120];
368 snprintf (message_totals, sizeof (message_totals),
369 "ok %zu - %s # { passed, %zu check%s in %zu "
379 snprintf (message_totals, sizeof (message_totals),
380 "not ok %zu - %s # { FAILED, %zu check%s "
381 "passed, %zu failed, in %zu test case%s",
390 char message_time[120] = "";
391 if (milliseconds > 0 || microseconds > 0)
393 snprintf (message_time, sizeof (message_time),
394 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
402 fprintf (output_file_, "%s\n%s%s }\n", message_summary, message_totals,
426 printf ("%s\n%s%s }\n", message_summary, message_totals,
437 printf ("%s\n%s%s }\n", message_summary, message_totals,
449#pragma GCC diagnostic pop
466#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
467#pragma GCC diagnostic push
468#if defined(__clang__)
469#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
471 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, subtest.name ());
472#pragma GCC diagnostic pop
476#pragma GCC diagnostic push
477#if defined(__clang__)
478#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
492 char message_subtest[120];
493 snprintf (message_subtest, sizeof (message_subtest), "%s# Subtest: %s",
508 printf ("%s\n", message_subtest);
516#pragma GCC diagnostic pop
532#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
533#pragma GCC diagnostic push
534#if defined(__clang__)
535#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
537 trace::printf ("%s '%s' i%zu +%zu -%zu in xc%zu, xs%zu | cs%zu\n",
545#pragma GCC diagnostic pop
549#pragma GCC diagnostic push
550#if defined(__clang__)
551#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
558 char message_summary[40];
559 snprintf (message_summary, sizeof (message_summary), "%s1..%zu",
564 char message_totals[120];
567 snprintf (message_totals, sizeof (message_totals),
568 "%sok %zu - %s # { passed, %zu check%s }", indent.c_str (),
575 snprintf (message_totals, sizeof (message_totals),
576 "%snot ok %zu - %s # { FAILED, %zu check%s "
577 "passed, %zu failed }",
588 fprintf (output_file_, "%s\n%s\n", message_summary, message_totals);
609 printf ("%s\n", message_summary);
616 printf ("%s1..%zu\n", indent2.c_str (),
620 printf ("%s\n", message_totals);
631 printf ("%s\n%s\n", message_summary, message_totals);
642#pragma GCC diagnostic pop
676 *this << indent (level + 1) << "ok "
678 if (!message.empty ())
680 *this << message.c_str ();
711 std::string& message, const bool has_expression,
716 *this << indent (level + 1) << "not ok "
719 if (!message.empty ())
721 *this << " - " << message.c_str ();
727 *this << indent (level + 1) << " ---";
731 *this << indent (level + 1) << " condition: ";
749 *this << " aborted...";
756 *this << indent (level + 1) << " at:" << endl;
757 *this << indent (level + 1)
760 *this << indent (level + 1) << " line: " << location.line () << endl;
762 *this << indent (level + 1) << " ..." << endl;
Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.17.0.