C++ source file with implementations for the µTest++ human test reporter methods. More...
Namespaces Index
Variables Index
Description
C++ source file with implementations for the µTest++ human test reporter methods.
This source file contains the implementations for reporter_human, the default concrete implementation of the reporter abstract interface. It formats and presents test results using printf-based standard output, accumulating output in an internal string buffer and supporting colour-coded diagnostics and multiple verbosity levels.
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.
Variables
indent_size
| size_t micro_os_plus::micro_test_plus::indent_size = 4 |
|
constexpr
|
File Listing
The file content with the documentation metadata removed is:
39#if __has_include(<micro-os-plus/project-config.h>)
40#include <micro-os-plus/project-config.h>
41#elif __has_include(<micro-os-plus/config.h>)
43 "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"
44#include <micro-os-plus/config.h>
47#if __has_include(<micro-os-plus/micro-test-plus-defines.h>)
48#include <micro-os-plus/micro-test-plus-defines.h>
51#if defined(MICRO_OS_PLUS_TRACE)
52#include <micro-os-plus/diag/trace.h>
62#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
70#pragma GCC diagnostic ignored "-Waggregate-return"
72#pragma clang diagnostic ignored "-Wunknown-warning-option"
73#pragma clang diagnostic ignored "-Wc++98-compat"
74#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
93 std::unique_ptr<std::vector<std::string_view>> argvs)
96#if defined(MICRO_OS_PLUS_TRACE) \
97 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
98 trace::printf ("%s\n", __PRETTY_FUNCTION__);
101#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
102 if (isatty (fileno (stdout)))
117#if defined(MICRO_OS_PLUS_TRACE) \
118 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
119 trace::printf ("%s\n", __PRETTY_FUNCTION__);
161#if defined(MICRO_OS_PLUS_TRACE) \
162 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
163 trace::printf ("%s\n", __PRETTY_FUNCTION__);
167#pragma GCC diagnostic push
168#if defined(__clang__)
169#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
180 const char* message = "µTest++ human report";
188 printf ("%s\n", message);
196#pragma GCC diagnostic pop
212#if defined(MICRO_OS_PLUS_TRACE) \
213 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
214 trace::printf ("%s\n", __PRETTY_FUNCTION__);
218#pragma GCC diagnostic push
219#if defined(__clang__)
220#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
233 uint32_t milliseconds = 0;
234 uint32_t microseconds = 0;
241 char message_totals[300];
242 snprintf (message_totals, sizeof (message_totals),
243 "Total: %zu check%s passed, %zu failed, in %zu test "
244 "case%s, %zu test suite%s",
250 total_suites_count, total_suites_count == 1 ? "" : "s");
252 char message_time[120] = "";
253 if (milliseconds > 0 || microseconds > 0)
255 snprintf (message_time, sizeof (message_time),
256 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
269 message_totals, message_time);
280 message_totals, message_time);
287#pragma GCC diagnostic pop
306#if defined(MICRO_OS_PLUS_TRACE) \
307 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
308#pragma GCC diagnostic push
309#if defined(__clang__)
310#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
312 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
313#pragma GCC diagnostic pop
317#pragma GCC diagnostic push
318#if defined(__clang__)
319#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
343#pragma GCC diagnostic pop
362#if defined(MICRO_OS_PLUS_TRACE) \
363 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
365#pragma GCC diagnostic push
366#if defined(__clang__)
367#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
370 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
372#pragma GCC diagnostic pop
377#pragma GCC diagnostic push
378#if defined(__clang__)
379#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
383 uint32_t milliseconds = 0;
384 uint32_t microseconds = 0;
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,
413 char message_totals[300];
414 snprintf (message_totals, sizeof (message_totals),
415 "(%zu check%s in %zu test case%s)",
426 message_totals, message_time);
437 suite.name (), message_totals, message_time);
443 char message_totals[300];
444 snprintf (message_totals, sizeof (message_totals),
445 "(%zu check%s passed, %zu "
446 "failed, in %zu test case%s)",
458 message_totals, message_time);
465 printf ("%s✗%s %s - %sFAILED%s %s%s\n", colours_.fail,
467 message_totals, message_time);
479#pragma GCC diagnostic pop
499#if defined(MICRO_OS_PLUS_TRACE) \
500 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
502#pragma GCC diagnostic push
503#if defined(__clang__)
504#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
507 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, subtest.name ());
509#pragma GCC diagnostic pop
514#pragma GCC diagnostic push
515#if defined(__clang__)
516#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
524 "Buffer not empty at the beginning of a test case:\n%s\n",
552#pragma GCC diagnostic pop
571#if defined(MICRO_OS_PLUS_TRACE) \
572 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
574#pragma GCC diagnostic push
575#if defined(__clang__)
576#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
579 trace::printf ("%s '%s' i%zu\n", __PRETTY_FUNCTION__, subtest.name (),
582#pragma GCC diagnostic pop
587#pragma GCC diagnostic push
588#if defined(__clang__)
589#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
610 char message_totals[300];
611 snprintf (message_totals, sizeof (message_totals),
646 char message_totals[300];
647 snprintf (message_totals, sizeof (message_totals),
648 "(%zu check%s passed, %zu failed)",
677 printf ("%s%s✗%s %s - %sFAILED%s %s\n", indent.c_str (),
691#pragma GCC diagnostic pop
725 *this << indent (level + 1);
727 if (!message.empty ())
729 *this << message.c_str ();
762 std::string& message, const bool has_expression,
766#pragma GCC diagnostic push
767#if defined(__clang__)
768#pragma clang diagnostic ignored "-Wsign-conversion"
769#elif defined(__GNUC__)
770#pragma GCC diagnostic ignored "-Wnarrowing"
771#pragma GCC diagnostic ignored "-Wsign-conversion"
777 *this << indent (level + 1);
779 if (!message.empty ())
781 *this << message.c_str ();
793#pragma GCC diagnostic pop
814 *this << " aborted...";
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.