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#include <micro-os-plus/diag/trace.h>
60#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
68#pragma GCC diagnostic ignored "-Waggregate-return"
70#pragma clang diagnostic ignored "-Wunknown-warning-option"
71#pragma clang diagnostic ignored "-Wc++98-compat"
72#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
91 std::unique_ptr<std::vector<std::string_view>> argvs)
94#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
95 trace::printf ("%s\n", __PRETTY_FUNCTION__);
98#if defined(__APPLE__) || defined(__linux__) || defined(__unix__)
99 if (isatty (fileno (stdout)))
114#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
115 trace::printf ("%s\n", __PRETTY_FUNCTION__);
157#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
158 trace::printf ("%s\n", __PRETTY_FUNCTION__);
162#pragma GCC diagnostic push
163#if defined(__clang__)
164#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
175 const char* message = "µTest++ human report";
183 printf ("%s\n", message);
191#pragma GCC diagnostic pop
207#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
208 trace::printf ("%s\n", __PRETTY_FUNCTION__);
212#pragma GCC diagnostic push
213#if defined(__clang__)
214#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
227 uint32_t milliseconds = 0;
228 uint32_t microseconds = 0;
235 char message_totals[300];
236 snprintf (message_totals, sizeof (message_totals),
237 "Total: %zu check%s passed, %zu failed, in %zu test "
238 "case%s, %zu test suite%s",
244 total_suites_count, total_suites_count == 1 ? "" : "s");
246 char message_time[120] = "";
247 if (milliseconds > 0 || microseconds > 0)
249 snprintf (message_time, sizeof (message_time),
250 ", time: %" PRIu32 ".%03" PRIu32 " ms", milliseconds,
263 message_totals, message_time);
274 message_totals, message_time);
281#pragma GCC diagnostic pop
300#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
301#pragma GCC diagnostic push
302#if defined(__clang__)
303#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
305 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite.name ());
306#pragma GCC diagnostic pop
310#pragma GCC diagnostic push
311#if defined(__clang__)
312#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
336#pragma GCC diagnostic pop
355#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
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_MICRO_TEST_PLUS_TRACE_ENABLED)
493#pragma GCC diagnostic push
494#if defined(__clang__)
495#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
498 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, subtest.name ());
500#pragma GCC diagnostic pop
505#pragma GCC diagnostic push
506#if defined(__clang__)
507#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
515 "Buffer not empty at the beginning of a test case:\n%s\n",
543#pragma GCC diagnostic pop
562#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
564#pragma GCC diagnostic push
565#if defined(__clang__)
566#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
569 trace::printf ("%s '%s' i%zu\n", __PRETTY_FUNCTION__, subtest.name (),
572#pragma GCC diagnostic pop
577#pragma GCC diagnostic push
578#if defined(__clang__)
579#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
600 char message_totals[300];
601 snprintf (message_totals, sizeof (message_totals),
636 char message_totals[300];
637 snprintf (message_totals, sizeof (message_totals),
638 "(%zu check%s passed, %zu failed)",
667 printf ("%s%s✗%s %s - %sFAILED%s %s\n", indent.c_str (),
681#pragma GCC diagnostic pop
715 *this << indent (level + 1);
717 if (!message.empty ())
719 *this << message.c_str ();
752 std::string& message, const bool has_expression,
756#pragma GCC diagnostic push
757#if defined(__clang__)
758#pragma clang diagnostic ignored "-Wsign-conversion"
759#elif defined(__GNUC__)
760#pragma GCC diagnostic ignored "-Wnarrowing"
761#pragma GCC diagnostic ignored "-Wsign-conversion"
767 *this << indent (level + 1);
769 if (!message.empty ())
771 *this << message.c_str ();
783#pragma GCC diagnostic pop
804 *this << " aborted...";
Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.17.0.