@micro-os-plus/micro-test-plus 4.0.0 → 4.1.1
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 +95 -0
- package/CMakeLists.txt +74 -24
- package/README.md +3 -2
- package/include/micro-os-plus/micro-test-plus/README.md +6 -0
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +29 -54
- package/include/micro-os-plus/micro-test-plus/detail.h +166 -705
- package/include/micro-os-plus/micro-test-plus/exceptions.h +5 -6
- package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +5 -0
- package/include/micro-os-plus/micro-test-plus/inlines/deferred-reporter-inlines.h +25 -30
- package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
- package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
- package/include/micro-os-plus/micro-test-plus/inlines/expression-formatter-inlines.h +510 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +17 -76
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +47 -25
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +7 -7
- package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +4 -4
- package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +53 -394
- package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +38 -0
- package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +231 -45
- package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
- package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +202 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +8 -14
- package/include/micro-os-plus/micro-test-plus/math.h +5 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +19 -169
- package/include/micro-os-plus/micro-test-plus/reflection.h +5 -12
- package/include/micro-os-plus/micro-test-plus/reporter-human.h +17 -11
- package/include/micro-os-plus/micro-test-plus/reporter-tap.h +14 -8
- package/include/micro-os-plus/micro-test-plus/reporter.h +101 -424
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +162 -176
- package/include/micro-os-plus/micro-test-plus/runner.h +61 -42
- package/include/micro-os-plus/micro-test-plus/test.h +450 -506
- package/include/micro-os-plus/micro-test-plus/timings.h +259 -262
- package/include/micro-os-plus/micro-test-plus/type-traits.h +30 -52
- package/include/micro-os-plus/micro-test-plus/utility.h +5 -4
- package/include/micro-os-plus/micro-test-plus.h +33 -24
- package/meson.build +1 -0
- package/package.json +11 -3
- package/src/deferred-reporter.cpp +21 -2
- package/src/expression-formatter.cpp +289 -0
- package/src/reflection.cpp +3 -1
- package/src/reporter-human.cpp +31 -37
- package/src/reporter-tap.cpp +25 -35
- package/src/reporter.cpp +36 -231
- package/src/runner-totals.cpp +6 -3
- package/src/runner.cpp +131 -25
- package/src/test.cpp +120 -113
- package/src/timings.cpp +6 -5
- package/src/utility.cpp +1 -1
package/src/runner.cpp
CHANGED
|
@@ -38,13 +38,21 @@
|
|
|
38
38
|
|
|
39
39
|
// ----------------------------------------------------------------------------
|
|
40
40
|
|
|
41
|
+
#include <algorithm>
|
|
42
|
+
#include <string>
|
|
43
|
+
|
|
41
44
|
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
42
45
|
#include <micro-os-plus/config.h>
|
|
43
46
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
44
47
|
|
|
45
|
-
#
|
|
48
|
+
#if defined(MICRO_OS_PLUS_TRACE)
|
|
46
49
|
#include <micro-os-plus/diag/trace.h>
|
|
47
|
-
#
|
|
50
|
+
#endif // MICRO_OS_PLUS_TRACE
|
|
51
|
+
|
|
52
|
+
#include "micro-os-plus/micro-test-plus/runner.h"
|
|
53
|
+
#include "micro-os-plus/micro-test-plus/utility.h"
|
|
54
|
+
#include "micro-os-plus/micro-test-plus/reporter-tap.h"
|
|
55
|
+
#include "micro-os-plus/micro-test-plus/reporter-human.h"
|
|
48
56
|
|
|
49
57
|
// ----------------------------------------------------------------------------
|
|
50
58
|
|
|
@@ -65,12 +73,59 @@ namespace micro_os_plus::micro_test_plus
|
|
|
65
73
|
|
|
66
74
|
/**
|
|
67
75
|
* @details
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
* Performs the `static_runner` to `runner` upcast where both types are
|
|
77
|
+
* complete, allowing headers with only forward declarations to request this
|
|
78
|
+
* conversion safely.
|
|
79
|
+
*/
|
|
80
|
+
runner&
|
|
81
|
+
detail::to_runner (static_runner& static_runner_ref) noexcept
|
|
82
|
+
{
|
|
83
|
+
return static_cast<runner&> (static_runner_ref);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @details
|
|
88
|
+
* Performs static-suite registration where `static_runner` is complete,
|
|
89
|
+
* allowing header-only template code to avoid direct dependence on
|
|
90
|
+
* `runner.h` include order.
|
|
91
|
+
*/
|
|
92
|
+
void
|
|
93
|
+
detail::register_static_suite (static_runner& static_runner_ref,
|
|
94
|
+
static_suite& static_suite_ref)
|
|
95
|
+
{
|
|
96
|
+
static_runner::register_static_suite (static_runner_ref, static_suite_ref);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// --------------------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @details
|
|
103
|
+
* The constructor initialises a new `runner` instance together with
|
|
104
|
+
* its top suite (`top_suite_`). If tracing is enabled, it outputs the
|
|
105
|
+
* function signature for diagnostic purposes.
|
|
106
|
+
*/
|
|
107
|
+
runner::runner (void) : test_node{ "runner" }, top_suite_{ "", *this }
|
|
108
|
+
{
|
|
109
|
+
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
110
|
+
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
111
|
+
#if defined(__GNUC__)
|
|
112
|
+
#pragma GCC diagnostic push
|
|
113
|
+
#if defined(__clang__)
|
|
114
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
115
|
+
#endif
|
|
116
|
+
#endif
|
|
117
|
+
trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name ());
|
|
118
|
+
#if defined(__GNUC__)
|
|
119
|
+
#pragma GCC diagnostic pop
|
|
120
|
+
#endif
|
|
121
|
+
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @details
|
|
126
|
+
* The constructor initialises a new `runner` instance together with
|
|
127
|
+
* its top suite (`top_suite_`). If tracing is enabled, it outputs the
|
|
128
|
+
* function signature for diagnostic purposes.
|
|
74
129
|
*/
|
|
75
130
|
runner::runner (const char* top_suite_name)
|
|
76
131
|
: test_node{ "runner" }, top_suite_{ top_suite_name, *this }
|
|
@@ -113,18 +168,18 @@ namespace micro_os_plus::micro_test_plus
|
|
|
113
168
|
#endif
|
|
114
169
|
/**
|
|
115
170
|
* @details
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
171
|
+
* Captures command-line arguments, selects the reporter implementation
|
|
172
|
+
* (`human` or `tap`), starts session timing, and emits the initial
|
|
173
|
+
* reporter notifications for the session and top suite.
|
|
174
|
+
*
|
|
175
|
+
* If the top suite name is not provided, it attempts to derive a name from
|
|
176
|
+
* `argv[0]` or defaults to "default suite".
|
|
177
|
+
*
|
|
178
|
+
* If tracing is enabled, the command-line arguments are
|
|
179
|
+
* also logged for diagnostic purposes.
|
|
125
180
|
*/
|
|
126
181
|
suite&
|
|
127
|
-
runner::initialise (int argc, char* argv[])
|
|
182
|
+
runner::initialise (int argc, char* argv[], const char* top_suite_name)
|
|
128
183
|
{
|
|
129
184
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
130
185
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
|
|
@@ -146,6 +201,38 @@ namespace micro_os_plus::micro_test_plus
|
|
|
146
201
|
#endif // defined(MICRO_OS_PLUS_DEBUG)
|
|
147
202
|
#endif // !defined(MICRO_OS_PLUS_INCLUDE_STARTUP)
|
|
148
203
|
|
|
204
|
+
if (strlen (top_suite_name) > 0)
|
|
205
|
+
{
|
|
206
|
+
// If provided by this call, use it, possibly override the
|
|
207
|
+
// deprecated constructor.
|
|
208
|
+
top_suite_name_ = top_suite_name;
|
|
209
|
+
top_suite_.name (top_suite_name_.c_str ());
|
|
210
|
+
}
|
|
211
|
+
else if (strlen (top_suite_.name ()) == 0)
|
|
212
|
+
{
|
|
213
|
+
// If not provided by the constructor or by this call, try to extract a
|
|
214
|
+
// name from argv[0], which is commonly the executable name. If that
|
|
215
|
+
// fails, use a default name.
|
|
216
|
+
if (argc > 0 && argv != nullptr && argv[0] != nullptr)
|
|
217
|
+
{
|
|
218
|
+
std::string_view top_suite_name_view{ utility::extract_file_name (
|
|
219
|
+
argv[0]) };
|
|
220
|
+
|
|
221
|
+
const auto dot_pos = top_suite_name_view.rfind ('.');
|
|
222
|
+
if (dot_pos != std::string_view::npos)
|
|
223
|
+
{
|
|
224
|
+
top_suite_name_view = top_suite_name_view.substr (0, dot_pos);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
top_suite_name_ = top_suite_name_view;
|
|
228
|
+
}
|
|
229
|
+
else
|
|
230
|
+
{
|
|
231
|
+
top_suite_name_ = "default suite";
|
|
232
|
+
}
|
|
233
|
+
top_suite_.name (top_suite_name_.c_str ());
|
|
234
|
+
}
|
|
235
|
+
|
|
149
236
|
std::vector<std::string_view> argvs (argv, argv + argc);
|
|
150
237
|
|
|
151
238
|
std::string_view reporter_name{ "tap" };
|
|
@@ -277,7 +364,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
277
364
|
// Run the child suite immediately.
|
|
278
365
|
suite_ptr->run ();
|
|
279
366
|
|
|
280
|
-
// Accumulate the totals from the
|
|
367
|
+
// Accumulate the totals from the child suite into the runner
|
|
281
368
|
// totals.
|
|
282
369
|
// DO NOT increment executed_subtests here.
|
|
283
370
|
totals_ += suite_ptr->totals ();
|
|
@@ -337,12 +424,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
337
424
|
|
|
338
425
|
/**
|
|
339
426
|
* @details
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* failure scenarios, ensuring that no further tests are run and that the
|
|
343
|
-
* cause of the failure can be promptly investigated. This approach provides
|
|
344
|
-
* a robust mechanism for enforcing strict test outcomes across all test
|
|
345
|
-
* cases and folders.
|
|
427
|
+
* Prints the source location of the fatal error to `stderr` and then
|
|
428
|
+
* terminates the process via `::abort()`.
|
|
346
429
|
*/
|
|
347
430
|
void
|
|
348
431
|
runner::abort (const reflection::source_location& sl)
|
|
@@ -391,6 +474,29 @@ namespace micro_os_plus::micro_test_plus
|
|
|
391
474
|
|
|
392
475
|
// ==========================================================================
|
|
393
476
|
|
|
477
|
+
/**
|
|
478
|
+
* @details
|
|
479
|
+
* Delegates construction to the `runner` base class.
|
|
480
|
+
* If tracing is enabled, the function signature
|
|
481
|
+
* and suite name are output for diagnostic purposes.
|
|
482
|
+
*/
|
|
483
|
+
static_runner::static_runner (void) : runner{}
|
|
484
|
+
{
|
|
485
|
+
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
486
|
+
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
487
|
+
#if defined(__GNUC__)
|
|
488
|
+
#pragma GCC diagnostic push
|
|
489
|
+
#if defined(__clang__)
|
|
490
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
491
|
+
#endif
|
|
492
|
+
#endif
|
|
493
|
+
trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name ());
|
|
494
|
+
#if defined(__GNUC__)
|
|
495
|
+
#pragma GCC diagnostic pop
|
|
496
|
+
#endif
|
|
497
|
+
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
498
|
+
}
|
|
499
|
+
|
|
394
500
|
/**
|
|
395
501
|
* @details
|
|
396
502
|
* Delegates construction to the `runner` base class with the given
|
package/src/test.cpp
CHANGED
|
@@ -47,8 +47,12 @@
|
|
|
47
47
|
#include <micro-os-plus/config.h>
|
|
48
48
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
49
49
|
|
|
50
|
-
#
|
|
50
|
+
#if defined(MICRO_OS_PLUS_TRACE)
|
|
51
51
|
#include <micro-os-plus/diag/trace.h>
|
|
52
|
+
#endif // MICRO_OS_PLUS_TRACE
|
|
53
|
+
|
|
54
|
+
#include "micro-os-plus/micro-test-plus/test.h"
|
|
55
|
+
#include "micro-os-plus/micro-test-plus/runner.h"
|
|
52
56
|
|
|
53
57
|
// ----------------------------------------------------------------------------
|
|
54
58
|
|
|
@@ -63,20 +67,22 @@
|
|
|
63
67
|
#endif
|
|
64
68
|
#endif
|
|
65
69
|
|
|
66
|
-
//
|
|
70
|
+
// ============================================================================
|
|
67
71
|
|
|
68
72
|
namespace micro_os_plus::micro_test_plus
|
|
69
73
|
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @details
|
|
74
|
-
* Stores the supplied @p name pointer, which is expected to point to
|
|
75
|
-
* a string with a lifetime exceeding that of this instance. If
|
|
76
|
-
* tracing is enabled, the name is output for diagnostic purposes.
|
|
77
|
-
*/
|
|
78
|
-
test_node::test_node (const char* name) : name_{ name }
|
|
74
|
+
namespace detail
|
|
79
75
|
{
|
|
76
|
+
// ========================================================================
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @details
|
|
80
|
+
* Stores the supplied @p name pointer, which is expected to point to
|
|
81
|
+
* a string with a lifetime exceeding that of this instance. If
|
|
82
|
+
* tracing is enabled, the name is output for diagnostic purposes.
|
|
83
|
+
*/
|
|
84
|
+
test_node::test_node (const char* name) : name_{ name }
|
|
85
|
+
{
|
|
80
86
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
81
87
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
82
88
|
#if defined(__GNUC__)
|
|
@@ -85,21 +91,21 @@ namespace micro_os_plus::micro_test_plus
|
|
|
85
91
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
86
92
|
#endif
|
|
87
93
|
#endif
|
|
88
|
-
|
|
94
|
+
trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
|
|
89
95
|
#if defined(__GNUC__)
|
|
90
96
|
#pragma GCC diagnostic pop
|
|
91
97
|
#endif
|
|
92
98
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @details
|
|
103
|
+
* No resources are owned by `test_node`; the destructor performs no
|
|
104
|
+
* explicit clean-up. If tracing is enabled, the node name is output
|
|
105
|
+
* for diagnostic purposes.
|
|
106
|
+
*/
|
|
107
|
+
test_node::~test_node ()
|
|
108
|
+
{
|
|
103
109
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
104
110
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
105
111
|
#if defined(__GNUC__)
|
|
@@ -108,29 +114,29 @@ namespace micro_os_plus::micro_test_plus
|
|
|
108
114
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
109
115
|
#endif
|
|
110
116
|
#endif
|
|
111
|
-
|
|
117
|
+
trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name_);
|
|
112
118
|
#if defined(__GNUC__)
|
|
113
119
|
#pragma GCC diagnostic pop
|
|
114
120
|
#endif
|
|
115
121
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ========================================================================
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @details
|
|
128
|
+
* The constructor initialises a new instance of the `runnable_base` class
|
|
129
|
+
* with the specified name. It sets up the internal state required for
|
|
130
|
+
* managing test cases within the suite. If tracing is enabled, the
|
|
131
|
+
* function signature is output for diagnostic purposes. The default test
|
|
132
|
+
* suite does not require explicit registration, ensuring seamless
|
|
133
|
+
* integration within the µTest++ framework and supporting organised test
|
|
134
|
+
* management across all files and folders.
|
|
135
|
+
*/
|
|
136
|
+
runnable_base::runnable_base (const char* name, class runner& runner,
|
|
137
|
+
size_t own_index)
|
|
138
|
+
: test_node{ name }, runner_{ runner }, own_index_{ own_index }
|
|
139
|
+
{
|
|
134
140
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
135
141
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
136
142
|
#if defined(__GNUC__)
|
|
@@ -139,22 +145,22 @@ namespace micro_os_plus::micro_test_plus
|
|
|
139
145
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
140
146
|
#endif
|
|
141
147
|
#endif
|
|
142
|
-
|
|
148
|
+
trace::printf ("%s '%s' %zu\n", __PRETTY_FUNCTION__, name, own_index_);
|
|
143
149
|
#if defined(__GNUC__)
|
|
144
150
|
#pragma GCC diagnostic pop
|
|
145
151
|
#endif
|
|
146
152
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @details
|
|
157
|
+
* The destructor releases any resources associated with the
|
|
158
|
+
* `runnable_base` instance. It ensures that the test suite is properly
|
|
159
|
+
* cleaned up after execution, supporting robust and reliable test
|
|
160
|
+
* management across all files and folders within the µTest++ framework.
|
|
161
|
+
*/
|
|
162
|
+
runnable_base::~runnable_base ()
|
|
163
|
+
{
|
|
158
164
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
159
165
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
160
166
|
#if defined(__GNUC__)
|
|
@@ -163,60 +169,60 @@ namespace micro_os_plus::micro_test_plus
|
|
|
163
169
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
164
170
|
#endif
|
|
165
171
|
#endif
|
|
166
|
-
|
|
172
|
+
trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name_);
|
|
167
173
|
#if defined(__GNUC__)
|
|
168
174
|
#pragma GCC diagnostic pop
|
|
169
175
|
#endif
|
|
170
176
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
171
177
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
178
|
+
// children_subtests_ holds unique_ptrs; destroyed automatically.
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @details
|
|
183
|
+
* Delegates immediately to `runner_.reporter()`, returning the
|
|
184
|
+
* reporter associated with the owning runner instance.
|
|
185
|
+
*/
|
|
186
|
+
[[nodiscard]] reporter&
|
|
187
|
+
runnable_base::reporter (void) const noexcept
|
|
188
|
+
{
|
|
189
|
+
return runner_.reporter ();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @details
|
|
194
|
+
* Delegates immediately to `runner_.abort()`, passing the supplied
|
|
195
|
+
* source location so that the error message identifies the call site
|
|
196
|
+
* before the process is terminated via `::abort()`.
|
|
197
|
+
*/
|
|
198
|
+
[[noreturn]] void
|
|
199
|
+
runnable_base::abort (const reflection::source_location& sl)
|
|
200
|
+
{
|
|
201
|
+
runner_.abort (sl);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @details
|
|
206
|
+
* Transfers ownership of @p child_test into `children_subtests_` and
|
|
207
|
+
* immediately invokes `subtest::run()` on the newly stored subtest.
|
|
208
|
+
* The parent's executed-subtest counter is then incremented. The
|
|
209
|
+
* child's check counters are intentionally not merged into the parent
|
|
210
|
+
* totals; each subtest reports only its own counters. The child's
|
|
211
|
+
* totals are, however, accumulated into @p suite so that the suite
|
|
212
|
+
* summary reflects all checks performed by its subtests.
|
|
213
|
+
*/
|
|
214
|
+
void
|
|
215
|
+
runnable_base::after_subtest_create_ (
|
|
216
|
+
std::unique_ptr<class subtest> child_test, suite& suite)
|
|
217
|
+
{
|
|
218
|
+
// Transfer ownership into the vector.
|
|
219
|
+
children_subtests_.push_back (std::move (child_test));
|
|
220
|
+
|
|
221
|
+
// Run the child test case immediately.
|
|
222
|
+
class subtest& subtest = *children_subtests_.back ();
|
|
223
|
+
subtest.run ();
|
|
224
|
+
|
|
225
|
+
// This test executed one more subtest.
|
|
220
226
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
221
227
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
222
228
|
#if defined(__GNUC__)
|
|
@@ -225,15 +231,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
225
231
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
226
232
|
#endif
|
|
227
233
|
#endif
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
trace::printf ("%s subtest '%s' executed one more subtest\n",
|
|
235
|
+
__PRETTY_FUNCTION__, name ());
|
|
230
236
|
#if defined(__GNUC__)
|
|
231
237
|
#pragma GCC diagnostic pop
|
|
232
238
|
#endif
|
|
233
239
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
totals ().increment_executed_subtests ();
|
|
241
|
+
// Do not accumulate the totals from the child test into the current test
|
|
242
|
+
// totals, each subtest shows only its counters.
|
|
237
243
|
|
|
238
244
|
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
239
245
|
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
@@ -243,23 +249,24 @@ namespace micro_os_plus::micro_test_plus
|
|
|
243
249
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
244
250
|
#endif
|
|
245
251
|
#endif
|
|
246
|
-
|
|
247
|
-
|
|
252
|
+
trace::printf ("%s suite '%s' totals\n", __PRETTY_FUNCTION__,
|
|
253
|
+
suite.name ());
|
|
248
254
|
#if defined(__GNUC__)
|
|
249
255
|
#pragma GCC diagnostic pop
|
|
250
256
|
#endif
|
|
251
257
|
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
252
258
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
259
|
+
// Accumulate the totals from the child test into the suite totals.
|
|
260
|
+
suite.totals () += subtest.totals ();
|
|
261
|
+
}
|
|
262
|
+
} // namespace detail
|
|
256
263
|
|
|
257
264
|
// ==========================================================================
|
|
258
265
|
|
|
259
266
|
/**
|
|
260
267
|
* @details
|
|
261
268
|
* The destructor releases any resources associated with the
|
|
262
|
-
* `
|
|
269
|
+
* `subtest` instance. If tracing is enabled, it outputs the
|
|
263
270
|
* function signature for diagnostic purposes. This ensures that the test
|
|
264
271
|
* suite is properly cleaned up after execution, supporting robust and
|
|
265
272
|
* reliable test management across all files and folders within the µTest++
|
package/src/timings.cpp
CHANGED
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
|
|
36
36
|
// ----------------------------------------------------------------------------
|
|
37
37
|
|
|
38
|
+
#include <cassert>
|
|
39
|
+
|
|
38
40
|
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
39
41
|
#include <micro-os-plus/config.h>
|
|
40
42
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
41
43
|
|
|
42
|
-
#include
|
|
43
|
-
|
|
44
|
-
#include <cassert>
|
|
44
|
+
#include "micro-os-plus/micro-test-plus/timings.h"
|
|
45
45
|
|
|
46
46
|
// ----------------------------------------------------------------------------
|
|
47
47
|
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
// ============================================================================
|
|
58
58
|
|
|
59
|
-
namespace micro_os_plus::micro_test_plus
|
|
59
|
+
namespace micro_os_plus::micro_test_plus::detail
|
|
60
60
|
{
|
|
61
61
|
// --------------------------------------------------------------------------
|
|
62
62
|
|
|
@@ -205,5 +205,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
// --------------------------------------------------------------------------
|
|
208
|
+
} // namespace micro_os_plus::micro_test_plus::detail
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
// ----------------------------------------------------------------------------
|
package/src/utility.cpp
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
#include <micro-os-plus/config.h>
|
|
39
39
|
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
40
40
|
|
|
41
|
-
#include
|
|
41
|
+
#include "micro-os-plus/micro-test-plus/utility.h"
|
|
42
42
|
|
|
43
43
|
// ----------------------------------------------------------------------------
|
|
44
44
|
|