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:
42#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
47#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
48#include <micro-os-plus/config.h>
51#if defined(MICRO_OS_PLUS_TRACE)
52#include <micro-os-plus/diag/trace.h>
62#pragma GCC diagnostic ignored "-Waggregate-return"
64#pragma clang diagnostic ignored "-Wunknown-warning-option"
65#pragma clang diagnostic ignored "-Wc++98-compat"
66#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
85 std::unique_ptr<std::vector<std::string_view>> argvs)
88#if defined(MICRO_OS_PLUS_TRACE) \
89 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
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_TRACE) \
110 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
111 trace::printf ("%s\n", __PRETTY_FUNCTION__);
153#if defined(MICRO_OS_PLUS_TRACE) \
154 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
155 trace::printf ("%s\n", __PRETTY_FUNCTION__);
159#pragma GCC diagnostic push
160#if defined(__clang__)
161#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
172 const char* message = "µTest++ human report";
180 printf ("%s\n", message);
188#pragma GCC diagnostic pop
204#if defined(MICRO_OS_PLUS_TRACE) \
205 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
206 trace::printf ("%s\n", __PRETTY_FUNCTION__);
210#pragma GCC diagnostic push
211#if defined(__clang__)
212#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
225 uint32_t milliseconds = 0;
226 uint32_t microseconds = 0;
233 char message_totals[300];
234 snprintf (message_totals, sizeof (message_totals),
235 "Total: %zu check%s passed, %zu failed, in %zu test "
236 "case%s, %zu test suite%s",
242 total_suites_count, total_suites_count == 1 ? "" : "s");
244 char message_time[120] = "";
245 if (milliseconds > 0 || microseconds > 0)
247 snprintf (message_time, sizeof (message_time),
248 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
261 message_totals, message_time);
272 message_totals, message_time);
279#pragma GCC diagnostic pop
298#if defined(MICRO_OS_PLUS_TRACE) \
299 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
300#pragma GCC diagnostic push
301#if defined(__clang__)
302#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
304 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
305#pragma GCC diagnostic pop
309#pragma GCC diagnostic push
310#if defined(__clang__)
311#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
335#pragma GCC diagnostic pop
354#if defined(MICRO_OS_PLUS_TRACE) \
355 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
357#pragma GCC diagnostic push
358#if defined(__clang__)
359#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
362 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
364#pragma GCC diagnostic pop
369#pragma GCC diagnostic push
370#if defined(__clang__)
371#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
375 uint32_t milliseconds = 0;
376 uint32_t microseconds = 0;
382 char message_time[120] = "";
383 if (milliseconds > 0 || microseconds > 0)
385 snprintf (message_time, sizeof (message_time),
386 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
405 char message_totals[300];
406 snprintf (message_totals, sizeof (message_totals),
407 "(%zu check%s in %zu test case%s)",
418 message_totals, message_time);
429 suite.name (), message_totals, message_time);
435 char message_totals[300];
436 snprintf (message_totals, sizeof (message_totals),
437 "(%zu check%s passed, %zu "
438 "failed, in %zu test case%s)",
450 message_totals, message_time);
457 printf ("%s✗%s %s - %sFAILED%s %s%s\n", colours_.fail,
459 message_totals, message_time);
471#pragma GCC diagnostic pop
491#if defined(MICRO_OS_PLUS_TRACE) \
492 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
494#pragma GCC diagnostic push
495#if defined(__clang__)
496#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
499 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, subtest.name ());
501#pragma GCC diagnostic pop
506#pragma GCC diagnostic push
507#if defined(__clang__)
508#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
516 "Buffer not empty at the beginning of a test case:\n%s\n",
544#pragma GCC diagnostic pop
563#if defined(MICRO_OS_PLUS_TRACE) \
564 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
566#pragma GCC diagnostic push
567#if defined(__clang__)
568#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
571 trace::printf ("%s '%s' i%zu\n", __PRETTY_FUNCTION__, subtest.name (),
574#pragma GCC diagnostic pop
579#pragma GCC diagnostic push
580#if defined(__clang__)
581#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
602 char message_totals[300];
603 snprintf (message_totals, sizeof (message_totals),
638 char message_totals[300];
639 snprintf (message_totals, sizeof (message_totals),
640 "(%zu check%s passed, %zu failed)",
669 printf ("%s%s✗%s %s - %sFAILED%s %s\n", indent.c_str (),
683#pragma GCC diagnostic pop
717 *this << indent (level + 1);
719 if (!message.empty ())
721 *this << message.c_str ();
754 std::string& message, const bool has_expression,
758#pragma GCC diagnostic push
759#if defined(__clang__)
760#pragma clang diagnostic ignored "-Wsign-conversion"
761#elif defined(__GNUC__)
762#pragma GCC diagnostic ignored "-Wnarrowing"
763#pragma GCC diagnostic ignored "-Wsign-conversion"
769 *this << indent (level + 1);
771 if (!message.empty ())
773 *this << message.c_str ();
785#pragma GCC diagnostic pop
806 *this << " aborted...";
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.