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:
43#if __has_include("micro-os-plus/diag/trace.h")
44#include "micro-os-plus/diag/trace.h"
50#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
58#pragma GCC diagnostic ignored "-Waggregate-return"
60#pragma clang diagnostic ignored "-Wunknown-warning-option"
61#pragma clang diagnostic ignored "-Wc++98-compat"
62#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
63#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
69#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
86 std::unique_ptr<std::vector<std::string_view>> argvs)
89#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
90 trace::printf ("%s\n", __PRETTY_FUNCTION__);
93#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
94 if (isatty (fileno (stdout)))
109#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
110 trace::printf ("%s\n", __PRETTY_FUNCTION__);
152#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
153 trace::printf ("%s\n", __PRETTY_FUNCTION__);
163 const char* message = "µTest++ human report";
171 printf ("%s\n", message);
191#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
192 trace::printf ("%s\n", __PRETTY_FUNCTION__);
204 uint32_t milliseconds = 0;
205 uint32_t microseconds = 0;
212 char message_totals[300];
213 snprintf (message_totals, sizeof (message_totals),
214 "Total: %zu check%s passed, %zu failed, in %zu test "
215 "case%s, %zu test suite%s",
221 total_suites_count, total_suites_count == 1 ? "" : "s");
223 char message_time[120] = "";
224 if (milliseconds > 0 || microseconds > 0)
226 snprintf (message_time, sizeof (message_time),
227 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
240 message_totals, message_time);
251 message_totals, message_time);
273#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
274 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
312#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
313 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
316 uint32_t milliseconds = 0;
317 uint32_t microseconds = 0;
323 char message_time[120] = "";
324 if (milliseconds > 0 || microseconds > 0)
326 snprintf (message_time, sizeof (message_time),
327 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
346 char message_totals[300];
347 snprintf (message_totals, sizeof (message_totals),
348 "(%zu check%s in %zu test case%s)",
359 message_totals, message_time);
370 suite.name (), message_totals, message_time);
376 char message_totals[300];
377 snprintf (message_totals, sizeof (message_totals),
378 "(%zu check%s passed, %zu "
379 "failed, in %zu test case%s)",
391 message_totals, message_time);
398 printf ("%s✗%s %s - %sFAILED%s %s%s\n", colours_.fail,
400 message_totals, message_time);
428#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
429 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, subtest.name ());
436 "Buffer not empty at the beginning of a test case:\n%s\n",
479#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
480 trace::printf ("%s '%s' i%zu\n", __PRETTY_FUNCTION__, subtest.name (),
501 char message_totals[300];
502 snprintf (message_totals, sizeof (message_totals),
537 char message_totals[300];
538 snprintf (message_totals, sizeof (message_totals),
539 "(%zu check%s passed, %zu failed)",
568 printf ("%s%s✗%s %s - %sFAILED%s %s\n", indent.c_str (),
612 *this << indent (level + 1);
614 if (!message.empty ())
616 *this << message.c_str ();
649 std::string& message, const bool has_expression,
653#pragma GCC diagnostic push
655#if defined(__clang__)
656#pragma clang diagnostic ignored "-Wsign-conversion"
657#elif defined(__GNUC__)
658#pragma GCC diagnostic ignored "-Wnarrowing"
659#pragma GCC diagnostic ignored "-Wsign-conversion"
665 *this << indent (level + 1);
667 if (!message.empty ())
669 *this << message.c_str ();
682#pragma GCC diagnostic pop
702 *this << " aborted...";
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.