@micro-os-plus/micro-test-plus 3.3.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +330 -2
- package/CMakeLists.txt +79 -23
- package/README.md +1 -1
- package/config/xcdl-build.json +11 -4
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +292 -0
- package/include/micro-os-plus/micro-test-plus/detail.h +462 -1076
- package/include/micro-os-plus/micro-test-plus/exceptions.h +126 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +10 -7
- package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +49 -22
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +67 -4
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +3 -6
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +21 -15
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +35 -17
- package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → reporter-inlines.h} +176 -106
- package/include/micro-os-plus/micro-test-plus/inlines/{test-suite-inlines.h → runner-inlines.h} +41 -43
- package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +369 -0
- package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +4 -3
- package/include/micro-os-plus/micro-test-plus/math.h +9 -6
- package/include/micro-os-plus/micro-test-plus/operators.h +38 -44
- package/include/micro-os-plus/micro-test-plus/reflection.h +15 -4
- package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +72 -72
- package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +69 -69
- package/include/micro-os-plus/micro-test-plus/{test-reporter.h → reporter.h} +296 -200
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +264 -0
- package/include/micro-os-plus/micro-test-plus/runner.h +453 -0
- package/include/micro-os-plus/micro-test-plus/test.h +1069 -0
- package/include/micro-os-plus/micro-test-plus/timings.h +366 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +239 -545
- package/include/micro-os-plus/micro-test-plus/utility.h +135 -0
- package/include/micro-os-plus/micro-test-plus.h +25 -228
- package/meson.build +10 -6
- package/package.json +1 -1
- package/src/deferred-reporter.cpp +118 -0
- package/src/reflection.cpp +95 -0
- package/src/reporter-human.cpp +822 -0
- package/src/reporter-tap.cpp +782 -0
- package/src/reporter.cpp +676 -0
- package/src/runner-totals.cpp +95 -0
- package/src/runner.cpp +563 -0
- package/src/test.cpp +496 -0
- package/src/timings.cpp +209 -0
- package/src/utility.cpp +163 -0
- package/.cmake-format.yaml +0 -11
- package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
- package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
- package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
- package/src/micro-test-plus.cpp +0 -316
- package/src/test-reporter-basic.cpp +0 -466
- package/src/test-reporter-tap.cpp +0 -530
- package/src/test-reporter.cpp +0 -399
- package/src/test-runner.cpp +0 -311
- package/src/test-suite.cpp +0 -304
package/src/reporter.cpp
ADDED
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
|
|
3
|
+
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose is hereby granted, under the terms of the MIT license.
|
|
7
|
+
*
|
|
8
|
+
* If a copy of the license was not distributed with this file, it can be
|
|
9
|
+
* obtained from https://opensource.org/licenses/mit.
|
|
10
|
+
*
|
|
11
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
13
|
+
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @file
|
|
20
|
+
* @brief C++ source file with implementations for the µTest++ test reporter
|
|
21
|
+
* methods.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This source file contains the core implementations for the test reporting
|
|
25
|
+
* facilities of the µTest++ framework. It provides the logic for formatting
|
|
26
|
+
* and outputting test results, including operator overloads for a wide range
|
|
27
|
+
* of value types, containers, and comparison expressions, as well as
|
|
28
|
+
* structured output for logical and exception-related assertions.
|
|
29
|
+
*
|
|
30
|
+
* The test reporter is responsible for presenting test outcomes in a clear,
|
|
31
|
+
* consistent, and expressive manner, supporting both value and pointer
|
|
32
|
+
* semantics, and providing detailed diagnostics for both successful and failed
|
|
33
|
+
* test cases. Special attention is given to formatting, colour highlighting,
|
|
34
|
+
* and extensibility, enabling professional and readable test reports suitable
|
|
35
|
+
* for embedded and general C++ development.
|
|
36
|
+
*
|
|
37
|
+
* All definitions reside within the `micro_os_plus::micro_test_plus`
|
|
38
|
+
* namespace, ensuring clear separation from user code and minimising the risk
|
|
39
|
+
* of naming conflicts.
|
|
40
|
+
*
|
|
41
|
+
* This file must be included when building the µTest++ library.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
47
|
+
#include <micro-os-plus/config.h>
|
|
48
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
49
|
+
|
|
50
|
+
#include <micro-os-plus/micro-test-plus.h>
|
|
51
|
+
#include <micro-os-plus/diag/trace.h>
|
|
52
|
+
|
|
53
|
+
// ----------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
#if defined(__GNUC__)
|
|
56
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
57
|
+
#if defined(__clang__)
|
|
58
|
+
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
|
59
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
60
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
61
|
+
#endif
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
// =============================================================================
|
|
65
|
+
|
|
66
|
+
namespace micro_os_plus::micro_test_plus
|
|
67
|
+
{
|
|
68
|
+
// --------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @details
|
|
72
|
+
* Moves the supplied argument vector into `argvs_` and scans it for
|
|
73
|
+
* the `--verbose`, `--quiet`, `--silent`, and `--output-file=` options,
|
|
74
|
+
* adjusting `verbosity_` and optionally opening the output file. If
|
|
75
|
+
* the output file path is specified but the file cannot be opened, the
|
|
76
|
+
* process exits with a diagnostic error message. The internal string
|
|
77
|
+
* buffer is pre-allocated to reduce dynamic allocation overhead.
|
|
78
|
+
*/
|
|
79
|
+
reporter::reporter (std::unique_ptr<std::vector<std::string_view>> argvs)
|
|
80
|
+
{
|
|
81
|
+
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
82
|
+
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
83
|
+
trace::printf ("%s\n", __PRETTY_FUNCTION__);
|
|
84
|
+
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
85
|
+
|
|
86
|
+
std::string_view output_file_sv{};
|
|
87
|
+
|
|
88
|
+
argvs_ = std::move (argvs);
|
|
89
|
+
|
|
90
|
+
static constexpr std::string_view output_file_prefix{ "--output-file=" };
|
|
91
|
+
if (argvs_)
|
|
92
|
+
{
|
|
93
|
+
const auto& args = *argvs_;
|
|
94
|
+
for (size_t i = 0; i < args.size (); ++i)
|
|
95
|
+
{
|
|
96
|
+
if (args[i] == "--verbose")
|
|
97
|
+
{
|
|
98
|
+
verbosity_ = verbosity::verbose;
|
|
99
|
+
}
|
|
100
|
+
else if (args[i] == "--quiet")
|
|
101
|
+
{
|
|
102
|
+
verbosity_ = verbosity::quiet;
|
|
103
|
+
}
|
|
104
|
+
else if (args[i] == "--silent")
|
|
105
|
+
{
|
|
106
|
+
verbosity_ = verbosity::silent;
|
|
107
|
+
}
|
|
108
|
+
else if (args[i].starts_with (output_file_prefix))
|
|
109
|
+
{
|
|
110
|
+
output_file_sv = args[i].substr (output_file_prefix.size ());
|
|
111
|
+
}
|
|
112
|
+
else if (args[i]
|
|
113
|
+
== output_file_prefix.substr (
|
|
114
|
+
0, output_file_prefix.size () - 1))
|
|
115
|
+
{
|
|
116
|
+
if (i + 1 < args.size ())
|
|
117
|
+
{
|
|
118
|
+
output_file_sv = args[++i];
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
{
|
|
122
|
+
fprintf (stderr, "error: --output-file option requires a "
|
|
123
|
+
"file path argument\n");
|
|
124
|
+
exit (1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!output_file_sv.empty ())
|
|
131
|
+
{
|
|
132
|
+
// .data() is safe: all string_views are views into argv[]
|
|
133
|
+
// entries, which are null-terminated C strings.
|
|
134
|
+
output_file_ = fopen (output_file_sv.data (), "w");
|
|
135
|
+
if (output_file_ == nullptr)
|
|
136
|
+
{
|
|
137
|
+
#if defined(__GNUC__)
|
|
138
|
+
#pragma GCC diagnostic push
|
|
139
|
+
#if defined(__clang__)
|
|
140
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
141
|
+
#endif
|
|
142
|
+
#endif
|
|
143
|
+
fprintf (stderr, "error: Failed to open output file '%.*s'\n",
|
|
144
|
+
static_cast<int> (output_file_sv.size ()),
|
|
145
|
+
output_file_sv.data ());
|
|
146
|
+
#if defined(__GNUC__)
|
|
147
|
+
#pragma GCC diagnostic pop
|
|
148
|
+
#endif
|
|
149
|
+
exit (1);
|
|
150
|
+
}
|
|
151
|
+
// The original string is zero terminated, so we can safely use .data()
|
|
152
|
+
// here.
|
|
153
|
+
output_file_path_ = output_file_sv.data ();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Pre-allocate buffer to reduce dynamic allocations.
|
|
157
|
+
buffer_.reserve (128);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @details
|
|
162
|
+
* If an output file was opened, it is flushed and closed, and a
|
|
163
|
+
* confirmation message naming the output file is written to `stdout`.
|
|
164
|
+
* If tracing is enabled, the function signature is output for
|
|
165
|
+
* diagnostic purposes.
|
|
166
|
+
*/
|
|
167
|
+
reporter::~reporter ()
|
|
168
|
+
{
|
|
169
|
+
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
170
|
+
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
171
|
+
trace::printf ("%s\n", __PRETTY_FUNCTION__);
|
|
172
|
+
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
173
|
+
|
|
174
|
+
if (output_file_ != nullptr)
|
|
175
|
+
{
|
|
176
|
+
fflush (output_file_);
|
|
177
|
+
fclose (output_file_);
|
|
178
|
+
|
|
179
|
+
#if defined(__GNUC__)
|
|
180
|
+
#pragma GCC diagnostic push
|
|
181
|
+
#if defined(__clang__)
|
|
182
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
183
|
+
#endif
|
|
184
|
+
#endif
|
|
185
|
+
printf ("Test output written to '%s'.\n", output_file_path_);
|
|
186
|
+
#if defined(__GNUC__)
|
|
187
|
+
#pragma GCC diagnostic pop
|
|
188
|
+
#endif
|
|
189
|
+
|
|
190
|
+
output_file_ = nullptr;
|
|
191
|
+
output_file_path_ = nullptr;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// --------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @details
|
|
199
|
+
* The `endl` function inserts a newline character into the specified
|
|
200
|
+
* `reporter` stream and flushes its output buffer. This operation
|
|
201
|
+
* ensures that each test output line is clearly separated and immediately
|
|
202
|
+
* visible, facilitating the readability and clarity of test results across
|
|
203
|
+
* all test cases and folders within the µTest++ framework.
|
|
204
|
+
*/
|
|
205
|
+
reporter&
|
|
206
|
+
endl (reporter& stream)
|
|
207
|
+
{
|
|
208
|
+
stream.endline ();
|
|
209
|
+
return stream;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @details
|
|
214
|
+
* This method appends a newline character to the internal output buffer of
|
|
215
|
+
* the `reporter` and immediately flushes the stream. This ensures that
|
|
216
|
+
* each line of test output is clearly separated and promptly displayed,
|
|
217
|
+
* enhancing the readability and organisation of test results across all test
|
|
218
|
+
* cases and folders.
|
|
219
|
+
*/
|
|
220
|
+
void
|
|
221
|
+
reporter::endline (void)
|
|
222
|
+
{
|
|
223
|
+
buffer_.append ("\n");
|
|
224
|
+
flush ();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @details
|
|
229
|
+
* This method writes the contents of the internal output buffer to the
|
|
230
|
+
* standard output stream without appending a newline character. After
|
|
231
|
+
* outputting the buffer, it is cleared to prepare for subsequent output.
|
|
232
|
+
* This approach ensures that test results are presented promptly and
|
|
233
|
+
* efficiently, supporting clear and organised reporting across all test
|
|
234
|
+
* cases and folders.
|
|
235
|
+
*/
|
|
236
|
+
void
|
|
237
|
+
reporter::write_buffer_to_stdout (void)
|
|
238
|
+
{
|
|
239
|
+
// Pass only the string, do not add an `\n` here.
|
|
240
|
+
printf ("%s", buffer_.c_str ());
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @details
|
|
245
|
+
* Writes the contents of `buffer_` to `output_file_` using `fprintf`
|
|
246
|
+
* without appending a newline. If `output_file_` is null, the call is
|
|
247
|
+
* a no-op.
|
|
248
|
+
*/
|
|
249
|
+
void
|
|
250
|
+
reporter::write_buffer_to_file_ (void)
|
|
251
|
+
{
|
|
252
|
+
// Pass only the string, do not add an `\n` here.
|
|
253
|
+
if (output_file_ != nullptr)
|
|
254
|
+
{
|
|
255
|
+
fprintf (output_file_, "%s", buffer_.c_str ());
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @details
|
|
261
|
+
* Constructs and emits two informational lines: the first lists the
|
|
262
|
+
* programme name and any command-line arguments; the second identifies
|
|
263
|
+
* the compiler (Clang, GCC, or MSVC) together with the version string,
|
|
264
|
+
* floating-point availability on bare-metal targets, exception support,
|
|
265
|
+
* and any active debug or trace macros. Both lines are written to the
|
|
266
|
+
* output file when one is open, and to `stdout` unless verbosity is
|
|
267
|
+
* set to `silent`.
|
|
268
|
+
*/
|
|
269
|
+
void
|
|
270
|
+
reporter::write_info_ (void)
|
|
271
|
+
{
|
|
272
|
+
if (argvs_ && !argvs_->empty ())
|
|
273
|
+
{
|
|
274
|
+
const auto& args = *argvs_;
|
|
275
|
+
std::string line;
|
|
276
|
+
line.reserve (256);
|
|
277
|
+
line.append (get_comment_prefix ());
|
|
278
|
+
line.append ("Running: ");
|
|
279
|
+
|
|
280
|
+
// Append only the file name part of argv[0].
|
|
281
|
+
const std::string_view arg0 = args[0];
|
|
282
|
+
const auto sep = arg0.rfind ('/');
|
|
283
|
+
line.append ((sep != std::string_view::npos) ? arg0.substr (sep + 1)
|
|
284
|
+
: arg0);
|
|
285
|
+
|
|
286
|
+
for (size_t i = 1; i < args.size (); ++i)
|
|
287
|
+
{
|
|
288
|
+
line.append (" ");
|
|
289
|
+
line.append (args[i]);
|
|
290
|
+
}
|
|
291
|
+
line.append ("\n");
|
|
292
|
+
|
|
293
|
+
if (output_file_ != nullptr)
|
|
294
|
+
fprintf (output_file_, "%s", line.c_str ());
|
|
295
|
+
|
|
296
|
+
#if !(defined(MICRO_OS_PLUS_INCLUDE_STARTUP) && defined(MICRO_OS_PLUS_TRACE))
|
|
297
|
+
if (verbosity_ == verbosity::normal
|
|
298
|
+
|| verbosity_ == verbosity::verbose)
|
|
299
|
+
printf ("%s", line.c_str ());
|
|
300
|
+
#endif // !defined(MICRO_OS_PLUS_INCLUDE_STARTUP)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
{
|
|
304
|
+
// Build the "Built with ..." line. For the output file the compiler
|
|
305
|
+
// version is omitted; for stdout it is appended via __VERSION__.
|
|
306
|
+
std::string line;
|
|
307
|
+
line.reserve (256);
|
|
308
|
+
line.append (get_comment_prefix ());
|
|
309
|
+
line.append ("Built with ");
|
|
310
|
+
#if defined(__clang__)
|
|
311
|
+
line.append ("clang " __VERSION__);
|
|
312
|
+
#elif defined(__GNUC__)
|
|
313
|
+
line.append ("GCC " __VERSION__);
|
|
314
|
+
#elif defined(_MSC_VER)
|
|
315
|
+
line.append ("MSVC");
|
|
316
|
+
char msvc_ver[16];
|
|
317
|
+
snprintf (msvc_ver, sizeof (msvc_ver), " - %d", _MSC_VER);
|
|
318
|
+
line.append (msvc_ver);
|
|
319
|
+
#else
|
|
320
|
+
line.append ("an unknown compiler");
|
|
321
|
+
#endif
|
|
322
|
+
#if !(defined(__APPLE__) || defined(__linux__) || defined(__unix__) \
|
|
323
|
+
|| defined(WIN32))
|
|
324
|
+
// This is relevant only on bare-metal.
|
|
325
|
+
#if defined(__ARM_PCS_VFP) || defined(__ARM_FP)
|
|
326
|
+
line.append (", with FP");
|
|
327
|
+
#else
|
|
328
|
+
line.append (", no FP");
|
|
329
|
+
#endif
|
|
330
|
+
#endif
|
|
331
|
+
#if defined(__EXCEPTIONS)
|
|
332
|
+
line.append (", with exceptions");
|
|
333
|
+
#else
|
|
334
|
+
line.append (", no exceptions");
|
|
335
|
+
#endif
|
|
336
|
+
#if defined(MICRO_OS_PLUS_DEBUG)
|
|
337
|
+
line.append (", with MICRO_OS_PLUS_DEBUG");
|
|
338
|
+
#endif
|
|
339
|
+
#if defined(MICRO_OS_PLUS_TRACE)
|
|
340
|
+
line.append (", with MICRO_OS_PLUS_TRACE");
|
|
341
|
+
#endif
|
|
342
|
+
|
|
343
|
+
if (output_file_ != nullptr)
|
|
344
|
+
{
|
|
345
|
+
fprintf (output_file_, "%s\n", line.c_str ());
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
#if !(defined(MICRO_OS_PLUS_INCLUDE_STARTUP) && defined(MICRO_OS_PLUS_TRACE))
|
|
349
|
+
if (verbosity_ == verbosity::normal || verbosity_ == verbosity::verbose)
|
|
350
|
+
{
|
|
351
|
+
printf ("%s\n", line.c_str ());
|
|
352
|
+
}
|
|
353
|
+
#endif // !defined(MICRO_OS_PLUS_INCLUDE_STARTUP)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @details
|
|
359
|
+
* This method flushes the output buffer of the `reporter` by
|
|
360
|
+
* synchronising it with the standard output stream. This guarantees that all
|
|
361
|
+
* pending test output is immediately written and visible, ensuring prompt
|
|
362
|
+
* and reliable reporting of test results across all test cases and folders.
|
|
363
|
+
*/
|
|
364
|
+
void
|
|
365
|
+
reporter::flush (void)
|
|
366
|
+
{
|
|
367
|
+
fflush (stdout);
|
|
368
|
+
if (output_file_ != nullptr)
|
|
369
|
+
{
|
|
370
|
+
fflush (output_file_);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// --------------------------------------------------------------------------
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @details
|
|
378
|
+
* This operator overload enables manipulators, such as `endl`, to be used
|
|
379
|
+
* with the `reporter` stream in a manner similar to standard C++
|
|
380
|
+
* streams. When a manipulator function is passed, it is invoked with the
|
|
381
|
+
* current `reporter` instance, allowing for seamless integration of
|
|
382
|
+
* stream operations and improved readability of test output across all test
|
|
383
|
+
* cases and folders.
|
|
384
|
+
*/
|
|
385
|
+
reporter&
|
|
386
|
+
reporter::operator<< (reporter& (*func) (reporter&))
|
|
387
|
+
{
|
|
388
|
+
// Call the endl function.
|
|
389
|
+
(*func) (*this);
|
|
390
|
+
return *this;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* @details
|
|
395
|
+
* This operator overload appends the contents of the provided
|
|
396
|
+
* `std::string_view` to the internal output buffer of the `reporter`.
|
|
397
|
+
* It enables seamless streaming of string data into the reporter, supporting
|
|
398
|
+
* clear and efficient formatting of test output across all test cases and
|
|
399
|
+
* folders.
|
|
400
|
+
*/
|
|
401
|
+
reporter&
|
|
402
|
+
reporter::operator<< (std::string_view sv)
|
|
403
|
+
{
|
|
404
|
+
buffer_.append (sv);
|
|
405
|
+
return *this;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* @details
|
|
410
|
+
* This operator overload appends the specified character to the internal
|
|
411
|
+
* output buffer of the `reporter`. It enables efficient streaming of
|
|
412
|
+
* individual characters into the reporter, supporting precise and flexible
|
|
413
|
+
* formatting of test output across all test cases and folders.
|
|
414
|
+
*/
|
|
415
|
+
reporter&
|
|
416
|
+
reporter::operator<< (char c)
|
|
417
|
+
{
|
|
418
|
+
buffer_.append (1, c);
|
|
419
|
+
return *this;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @details
|
|
424
|
+
* This operator overload appends the contents of the provided C-style string
|
|
425
|
+
* to the internal output buffer of the `reporter`. It enables efficient
|
|
426
|
+
* streaming of string literals and character arrays into the reporter,
|
|
427
|
+
* supporting clear and flexible formatting of test output across all test
|
|
428
|
+
* cases and folders.
|
|
429
|
+
*/
|
|
430
|
+
reporter&
|
|
431
|
+
reporter::operator<< (const char* s)
|
|
432
|
+
{
|
|
433
|
+
buffer_.append (s);
|
|
434
|
+
return *this;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @details
|
|
439
|
+
* This operator overload appends the string representation of the specified
|
|
440
|
+
* boolean value to the internal output buffer of the `reporter`. It
|
|
441
|
+
* enables clear and direct streaming of boolean results into the reporter,
|
|
442
|
+
* supporting precise and readable formatting of test output across all test
|
|
443
|
+
* cases and folders.
|
|
444
|
+
*/
|
|
445
|
+
reporter&
|
|
446
|
+
reporter::operator<< (bool v)
|
|
447
|
+
{
|
|
448
|
+
buffer_.append (v ? "true" : "false");
|
|
449
|
+
return *this;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* @details
|
|
454
|
+
* This operator overload appends the string "nullptr" to the internal output
|
|
455
|
+
* buffer of the `reporter`. It enables clear and explicit streaming of
|
|
456
|
+
* null pointer values into the reporter, supporting precise and readable
|
|
457
|
+
* formatting of test output across all test cases and folders.
|
|
458
|
+
*/
|
|
459
|
+
reporter&
|
|
460
|
+
reporter::operator<< (std::nullptr_t)
|
|
461
|
+
{
|
|
462
|
+
buffer_.append ("nullptr");
|
|
463
|
+
return *this;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @details
|
|
468
|
+
* This operator overload appends the string representation of the specified
|
|
469
|
+
* signed character to the internal output buffer of the `reporter`. It
|
|
470
|
+
* enables precise and readable streaming of character values into the
|
|
471
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
472
|
+
* and folders.
|
|
473
|
+
*/
|
|
474
|
+
reporter&
|
|
475
|
+
reporter::operator<< (signed char c)
|
|
476
|
+
{
|
|
477
|
+
append_number_ (buffer_, c);
|
|
478
|
+
buffer_.append ("c");
|
|
479
|
+
return *this;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* @details
|
|
484
|
+
* This operator overload appends the string representation of the specified
|
|
485
|
+
* unsigned character to the internal output buffer of the `reporter`.
|
|
486
|
+
* It enables precise and readable streaming of unsigned character values
|
|
487
|
+
* into the reporter, supporting clear formatting of test output across all
|
|
488
|
+
* test cases and folders.
|
|
489
|
+
*/
|
|
490
|
+
reporter&
|
|
491
|
+
reporter::operator<< (unsigned char c)
|
|
492
|
+
{
|
|
493
|
+
append_number_ (buffer_, c);
|
|
494
|
+
buffer_.append ("uc");
|
|
495
|
+
return *this;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @details
|
|
500
|
+
* This operator overload appends the string representation of the specified
|
|
501
|
+
* signed short integer to the internal output buffer of the `reporter`.
|
|
502
|
+
* It enables precise and readable streaming of signed short values into the
|
|
503
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
504
|
+
* and folders.
|
|
505
|
+
*/
|
|
506
|
+
reporter&
|
|
507
|
+
reporter::operator<< (signed short v)
|
|
508
|
+
{
|
|
509
|
+
append_number_ (buffer_, v);
|
|
510
|
+
buffer_.append ("s");
|
|
511
|
+
return *this;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* @details
|
|
516
|
+
* This operator overload appends the string representation of the specified
|
|
517
|
+
* unsigned short integer to the internal output buffer of the
|
|
518
|
+
* `reporter`. It enables precise and readable streaming of unsigned
|
|
519
|
+
* short values into the reporter, supporting clear formatting of test output
|
|
520
|
+
* across all test cases and folders.
|
|
521
|
+
*/
|
|
522
|
+
reporter&
|
|
523
|
+
reporter::operator<< (unsigned short v)
|
|
524
|
+
{
|
|
525
|
+
append_number_ (buffer_, v);
|
|
526
|
+
buffer_.append ("us");
|
|
527
|
+
return *this;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* @details
|
|
532
|
+
* This operator overload appends the string representation of the specified
|
|
533
|
+
* signed integer to the internal output buffer of the `reporter`. It
|
|
534
|
+
* enables precise and readable streaming of signed integer values into the
|
|
535
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
536
|
+
* and folders.
|
|
537
|
+
*/
|
|
538
|
+
reporter&
|
|
539
|
+
reporter::operator<< (signed int v)
|
|
540
|
+
{
|
|
541
|
+
append_number_ (buffer_, v);
|
|
542
|
+
return *this;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* @details
|
|
547
|
+
* This operator overload appends the string representation of the specified
|
|
548
|
+
* unsigned integer to the internal output buffer of the `reporter`. It
|
|
549
|
+
* enables precise and readable streaming of unsigned integer values into the
|
|
550
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
551
|
+
* and folders.
|
|
552
|
+
*/
|
|
553
|
+
reporter&
|
|
554
|
+
reporter::operator<< (unsigned int v)
|
|
555
|
+
{
|
|
556
|
+
append_number_ (buffer_, v);
|
|
557
|
+
buffer_.append ("u");
|
|
558
|
+
return *this;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @details
|
|
563
|
+
* This operator overload appends the string representation of the specified
|
|
564
|
+
* signed long integer to the internal output buffer of the `reporter`.
|
|
565
|
+
* It enables precise and readable streaming of signed long values into the
|
|
566
|
+
* reporter, supporting clear formatting of test output across all test cases
|
|
567
|
+
* and folders.
|
|
568
|
+
*/
|
|
569
|
+
reporter&
|
|
570
|
+
reporter::operator<< (signed long v)
|
|
571
|
+
{
|
|
572
|
+
append_number_ (buffer_, v);
|
|
573
|
+
buffer_.append ("l");
|
|
574
|
+
return *this;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @details
|
|
579
|
+
* This operator overload appends the string representation of the specified
|
|
580
|
+
* unsigned long integer to the internal output buffer of the
|
|
581
|
+
* `reporter`. It enables precise and readable streaming of unsigned
|
|
582
|
+
* long values into the reporter, supporting clear formatting of test output
|
|
583
|
+
* across all test cases and folders.
|
|
584
|
+
*/
|
|
585
|
+
reporter&
|
|
586
|
+
reporter::operator<< (unsigned long v)
|
|
587
|
+
{
|
|
588
|
+
append_number_ (buffer_, v);
|
|
589
|
+
buffer_.append ("ul");
|
|
590
|
+
return *this;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* @details
|
|
595
|
+
* This operator overload appends the string representation of the specified
|
|
596
|
+
* signed long long integer to the internal output buffer of the
|
|
597
|
+
* `reporter`. It enables precise and readable streaming of signed long
|
|
598
|
+
* long values into the reporter, supporting clear formatting of test output
|
|
599
|
+
* across all test cases and folders.
|
|
600
|
+
*/
|
|
601
|
+
reporter&
|
|
602
|
+
reporter::operator<< (signed long long v)
|
|
603
|
+
{
|
|
604
|
+
append_number_ (buffer_, v);
|
|
605
|
+
buffer_.append ("ll");
|
|
606
|
+
return *this;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* @details
|
|
611
|
+
* This operator overload appends the string representation of the specified
|
|
612
|
+
* unsigned long long integer to the internal output buffer of the
|
|
613
|
+
* `reporter`. It enables precise and readable streaming of unsigned
|
|
614
|
+
* long long values into the reporter, supporting clear formatting of test
|
|
615
|
+
* output across all test cases and folders.
|
|
616
|
+
*/
|
|
617
|
+
reporter&
|
|
618
|
+
reporter::operator<< (unsigned long long v)
|
|
619
|
+
{
|
|
620
|
+
append_number_ (buffer_, v);
|
|
621
|
+
buffer_.append ("ull");
|
|
622
|
+
return *this;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* @details
|
|
627
|
+
* This operator overload appends the string representation of the specified
|
|
628
|
+
* floating-point value to the internal output buffer of the `reporter`,
|
|
629
|
+
* followed by the character 'f' to indicate a float type. It enables precise
|
|
630
|
+
* and readable streaming of float values into the reporter, supporting clear
|
|
631
|
+
* formatting of test output across all test cases and folders.
|
|
632
|
+
*/
|
|
633
|
+
reporter&
|
|
634
|
+
reporter::operator<< (float v)
|
|
635
|
+
{
|
|
636
|
+
append_number_ (buffer_, v);
|
|
637
|
+
buffer_.append ("f");
|
|
638
|
+
return *this;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* @details
|
|
643
|
+
* This operator overload appends the string representation of the specified
|
|
644
|
+
* double-precision floating-point value to the internal output buffer of the
|
|
645
|
+
* `reporter`. It enables precise and readable streaming of double
|
|
646
|
+
* values into the reporter, supporting clear formatting of test output
|
|
647
|
+
* across all test cases and folders.
|
|
648
|
+
*/
|
|
649
|
+
reporter&
|
|
650
|
+
reporter::operator<< (double v)
|
|
651
|
+
{
|
|
652
|
+
append_number_ (buffer_, v);
|
|
653
|
+
return *this;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @details
|
|
658
|
+
* This operator overload appends the string representation of the specified
|
|
659
|
+
* long double-precision floating-point value to the internal output buffer
|
|
660
|
+
* of the `reporter`, followed by the character 'l' to indicate a long
|
|
661
|
+
* double type. It enables precise and readable streaming of long double
|
|
662
|
+
* values into the reporter, supporting clear formatting of test output
|
|
663
|
+
* across all test cases and folders.
|
|
664
|
+
*/
|
|
665
|
+
reporter&
|
|
666
|
+
reporter::operator<< (long double v)
|
|
667
|
+
{
|
|
668
|
+
append_number_ (buffer_, v);
|
|
669
|
+
buffer_.append ("l");
|
|
670
|
+
return *this;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// --------------------------------------------------------------------------
|
|
674
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
675
|
+
|
|
676
|
+
// ----------------------------------------------------------------------------
|