C++ source file with implementations for the µTest++ test reporter methods. More...
Namespaces Index
Functions Index
| reporter & | endl (reporter &stream) |
|
Output stream manipulator for ending a line in test reports. More...
|
|
Description
C++ source file with implementations for the µTest++ test reporter methods.
This source file contains the core implementations for the test reporting facilities of the µTest++ framework. It provides lifecycle and utility behaviour for reporters, including command-line option parsing, output-file handling, informational banner emission, buffering helpers, stream operators, and pass/fail dispatch to reporter-specific prefix/ suffix hooks.
Concrete formatting behaviour is implemented by derived reporters (reporter_human and reporter_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.
Functions
endl()
| reporter & micro_os_plus::micro_test_plus::endl (reporter & stream) |
|
File Listing
The file content with the documentation metadata removed is:
43#if __has_include(<micro-os-plus/project-config.h>)
44#include <micro-os-plus/project-config.h>
45#elif __has_include(<micro-os-plus/config.h>)
47 "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"
48#include <micro-os-plus/config.h>
51#if __has_include(<micro-os-plus/micro-test-plus-defines.h>)
52#include <micro-os-plus/micro-test-plus-defines.h>
55#if defined(MICRO_OS_PLUS_TRACE)
56#include <micro-os-plus/diag/trace.h>
64#pragma GCC diagnostic ignored "-Waggregate-return"
66#pragma clang diagnostic ignored "-Wunknown-warning-option"
67#pragma clang diagnostic ignored "-Wc++98-compat"
68#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
89#if defined(MICRO_OS_PLUS_TRACE) \
90 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
91 trace::printf ("%s\n", __PRETTY_FUNCTION__);
94 std::string_view output_file_sv{};
96 argvs_ = std::move (argvs);
98 static constexpr std::string_view output_file_prefix{ "--output-file=" };
101 const auto& args = *argvs_;
102 for (size_t i = 0; i < args.size (); ++i)
104 if (args[i] == "--verbose")
108 else if (args[i] == "--quiet")
112 else if (args[i] == "--silent")
116 else if (args[i].starts_with (output_file_prefix))
118 output_file_sv = args[i].substr (output_file_prefix.size ());
121 == output_file_prefix.substr (
122 0, output_file_prefix.size () - 1))
124 if (i + 1 < args.size ())
126 output_file_sv = args[++i];
130 fprintf (stderr, "error: --output-file option requires a "
131 "file path argument\n");
138 if (!output_file_sv.empty ())
146#pragma GCC diagnostic push
147#if defined(__clang__)
148#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
151 fprintf (stderr, "error: Failed to open output file '%.*s'\n",
152 static_cast<int> (output_file_sv.size ()),
153 output_file_sv.data ());
155#pragma GCC diagnostic pop
177#if defined(MICRO_OS_PLUS_TRACE) \
178 && defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
179 trace::printf ("%s\n", __PRETTY_FUNCTION__);
188#pragma GCC diagnostic push
189#if defined(__clang__)
190#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
195#pragma GCC diagnostic pop
248 printf ("%s", buffer_.c_str ());
282 const auto& args = *argvs_;
286 line.append ("Running: ");
289 const std::string_view arg0 = args[0];
290 const auto sep = arg0.rfind ('/');
291 line.append ((sep != std::string_view::npos) ? arg0.substr (sep + 1)
294 for (size_t i = 1; i < args.size (); ++i)
297 line.append (args[i]);
304#if !(defined(MICRO_OS_PLUS_INCLUDE_STARTUP) && defined(MICRO_OS_PLUS_TRACE))
307 printf ("%s", line.c_str ());
317 line.append ("Built with ");
318#if defined(__clang__)
319 line.append ("clang " __VERSION__);
320#elif defined(__GNUC__)
321 line.append ("GCC " __VERSION__);
322#elif defined(_MSC_VER)
323 line.append ("MSVC");
325 snprintf (msvc_ver, sizeof (msvc_ver), " - %d", _MSC_VER);
326 line.append (msvc_ver);
328 line.append ("an unknown compiler");
330#if !(defined(__APPLE__) || defined(__linux__) || defined(__unix__) \
333#if defined(__ARM_PCS_VFP) || defined(__ARM_FP)
334 line.append (", with FP");
336 line.append (", no FP");
339#if defined(__EXCEPTIONS)
340 line.append (", with exceptions");
342 line.append (", no exceptions");
344#if defined(MICRO_OS_PLUS_DEBUG)
345 line.append (", with MICRO_OS_PLUS_DEBUG");
347#if defined(MICRO_OS_PLUS_TRACE)
348 line.append (", with MICRO_OS_PLUS_TRACE");
356#if !(defined(MICRO_OS_PLUS_INCLUDE_STARTUP) && defined(MICRO_OS_PLUS_TRACE))
359 printf ("%s\n", line.c_str ());
457 if (message.empty ())
472 const std::string& expression, bool has_expression,
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.