@micro-os-plus/micro-test-plus 3.3.1 → 4.1.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +412 -2
  2. package/CMakeLists.txt +134 -28
  3. package/README.md +3 -2
  4. package/config/xcdl-build.json +11 -4
  5. package/include/micro-os-plus/micro-test-plus/README.md +6 -0
  6. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +267 -0
  7. package/include/micro-os-plus/micro-test-plus/detail.h +272 -1425
  8. package/include/micro-os-plus/micro-test-plus/exceptions.h +125 -0
  9. package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
  10. package/include/micro-os-plus/micro-test-plus/function-comparators.h +15 -7
  11. package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +66 -44
  12. package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → expression-formatter-inlines.h} +232 -198
  15. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +24 -20
  16. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +50 -31
  17. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +25 -19
  18. package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
  19. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +39 -21
  20. package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +205 -0
  21. package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +151 -0
  22. package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
  23. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +555 -0
  24. package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
  25. package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +231 -0
  26. package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
  27. package/include/micro-os-plus/micro-test-plus/literals.h +12 -17
  28. package/include/micro-os-plus/micro-test-plus/math.h +14 -6
  29. package/include/micro-os-plus/micro-test-plus/operators.h +53 -209
  30. package/include/micro-os-plus/micro-test-plus/reflection.h +8 -4
  31. package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +80 -74
  32. package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +77 -71
  33. package/include/micro-os-plus/micro-test-plus/reporter.h +619 -0
  34. package/include/micro-os-plus/micro-test-plus/runner-totals.h +250 -0
  35. package/include/micro-os-plus/micro-test-plus/runner.h +472 -0
  36. package/include/micro-os-plus/micro-test-plus/test.h +1013 -0
  37. package/include/micro-os-plus/micro-test-plus/timings.h +363 -0
  38. package/include/micro-os-plus/micro-test-plus/type-traits.h +223 -577
  39. package/include/micro-os-plus/micro-test-plus/utility.h +136 -0
  40. package/include/micro-os-plus/micro-test-plus.h +42 -236
  41. package/meson.build +11 -6
  42. package/package.json +11 -3
  43. package/src/deferred-reporter.cpp +137 -0
  44. package/src/expression-formatter.cpp +289 -0
  45. package/src/reflection.cpp +97 -0
  46. package/src/reporter-human.cpp +816 -0
  47. package/src/reporter-tap.cpp +772 -0
  48. package/src/reporter.cpp +481 -0
  49. package/src/runner-totals.cpp +98 -0
  50. package/src/runner.cpp +669 -0
  51. package/src/test.cpp +503 -0
  52. package/src/timings.cpp +210 -0
  53. package/src/utility.cpp +163 -0
  54. package/.cmake-format.yaml +0 -11
  55. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
  56. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +0 -115
  57. package/include/micro-os-plus/micro-test-plus/test-reporter.h +0 -846
  58. package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
  59. package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
  60. package/src/micro-test-plus.cpp +0 -316
  61. package/src/test-reporter-basic.cpp +0 -466
  62. package/src/test-reporter-tap.cpp +0 -530
  63. package/src/test-reporter.cpp +0 -399
  64. package/src/test-runner.cpp +0 -311
  65. package/src/test-suite.cpp +0 -304
@@ -0,0 +1,250 @@
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++ header file with declarations for the µTest++ runner totals.
21
+ *
22
+ * @details
23
+ * This header provides the `runner_totals` class, which aggregates the
24
+ * counts of successful checks, failed checks, and executed subtests for a
25
+ * test runner, test suite, or subtest. Instances of this class are embedded
26
+ * inside every `test_node`-derived object and updated in place as the
27
+ * test session progresses.
28
+ *
29
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
30
+ * namespace, ensuring clear separation from user code and minimising the
31
+ * risk of naming conflicts.
32
+ *
33
+ * This file is intended solely for internal use within the framework and
34
+ * should not be included directly by user code.
35
+ */
36
+
37
+ #ifndef MICRO_TEST_PLUS_TEST_RUNNER_TOTALS_H_
38
+ #define MICRO_TEST_PLUS_TEST_RUNNER_TOTALS_H_
39
+
40
+ // ----------------------------------------------------------------------------
41
+
42
+ #ifdef __cplusplus
43
+
44
+ // ----------------------------------------------------------------------------
45
+
46
+ #include <cstddef>
47
+
48
+ // ----------------------------------------------------------------------------
49
+
50
+ #if defined(__GNUC__)
51
+ #pragma GCC diagnostic push
52
+ #if defined(__clang__)
53
+ #pragma clang diagnostic ignored "-Wc++98-compat"
54
+ #endif
55
+ #endif
56
+
57
+ // ============================================================================
58
+
59
+ namespace micro_os_plus::micro_test_plus
60
+ {
61
+ // --------------------------------------------------------------------------
62
+
63
+ namespace detail
64
+ {
65
+ // ========================================================================
66
+
67
+ /**
68
+ * @brief Aggregated pass/fail/subtest counters for a node in the test
69
+ * tree.
70
+ *
71
+ * @details
72
+ * `runner_totals` records three counters that are maintained throughout a
73
+ * test session:
74
+ * - the number of checks that passed (`successful_checks_`),
75
+ * - the number of checks that failed (`failed_checks_`), and
76
+ * - the number of subtests that were executed (`executed_subtests_`).
77
+ *
78
+ * Every `test_node`-derived object (`runner`, `suite`, `subtest`) owns a
79
+ * `runner_totals` member and accumulates its counts in place. At the end
80
+ * of each suite or session the operator `+=` propagates the child totals
81
+ * up to the parent node.
82
+ *
83
+ * The class is non-copyable and non-movable to prevent accidental
84
+ * duplication of live counters.
85
+ *
86
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
87
+ */
88
+ class runner_totals
89
+ {
90
+ public:
91
+ /**
92
+ * @brief Default constructor. All counters are zero-initialised.
93
+ */
94
+ runner_totals () = default;
95
+
96
+ /**
97
+ * @brief Deleted copy constructor to prevent copying.
98
+ */
99
+ runner_totals (const runner_totals&) = delete;
100
+
101
+ /**
102
+ * @brief Deleted move constructor to prevent moving.
103
+ */
104
+ runner_totals (runner_totals&&) = delete;
105
+
106
+ /**
107
+ * @brief Deleted copy assignment operator to prevent copying.
108
+ */
109
+ runner_totals&
110
+ operator= (const runner_totals&)
111
+ = delete;
112
+
113
+ /**
114
+ * @brief Deleted move assignment operator to prevent moving.
115
+ */
116
+ runner_totals&
117
+ operator= (runner_totals&&)
118
+ = delete;
119
+
120
+ /**
121
+ * @brief Accumulates the totals from another instance into this one.
122
+ *
123
+ * @param other The instance whose totals are to be added.
124
+ * @return Reference to this instance.
125
+ */
126
+ runner_totals&
127
+ operator+= (const runner_totals& other) noexcept;
128
+
129
+ /**
130
+ * @brief Increments the successful-checks counter.
131
+ *
132
+ * @param count The number of successful checks to add (default 1).
133
+ * @par Returns
134
+ * Nothing.
135
+ */
136
+ void
137
+ increment_successful_checks (size_t count = 1) noexcept;
138
+
139
+ /**
140
+ * @brief Increments the failed-checks counter.
141
+ *
142
+ * @param count The number of failed checks to add (default 1).
143
+ * @par Returns
144
+ * Nothing.
145
+ */
146
+ void
147
+ increment_failed_checks (size_t count = 1) noexcept;
148
+
149
+ /**
150
+ * @brief Increments the executed-subtests counter.
151
+ *
152
+ * @param count The number of subtests to add (default 1).
153
+ * @par Returns
154
+ * Nothing.
155
+ */
156
+ void
157
+ increment_executed_subtests (size_t count = 1) noexcept;
158
+
159
+ /**
160
+ * @brief Returns the number of checks that passed.
161
+ *
162
+ * @par Parameters
163
+ * None.
164
+ * @return The cumulative count of successful checks.
165
+ */
166
+ [[nodiscard]] size_t
167
+ successful_checks () const noexcept;
168
+
169
+ /**
170
+ * @brief Returns the number of checks that failed.
171
+ *
172
+ * @par Parameters
173
+ * None.
174
+ * @return The cumulative count of failed checks.
175
+ */
176
+ [[nodiscard]] size_t
177
+ failed_checks () const noexcept;
178
+
179
+ /**
180
+ * @brief Returns the total number of checks executed.
181
+ *
182
+ * @par Parameters
183
+ * None.
184
+ * @return The sum of successful and failed checks.
185
+ */
186
+ [[nodiscard]] size_t
187
+ executed_checks () const noexcept;
188
+
189
+ /**
190
+ * @brief Returns the number of subtests that were executed.
191
+ *
192
+ * @par Parameters
193
+ * None.
194
+ * @return The cumulative count of executed subtests.
195
+ */
196
+ [[nodiscard]] size_t
197
+ executed_subtests () const noexcept;
198
+
199
+ /**
200
+ * @brief Checks whether all executed checks were successful.
201
+ *
202
+ * @par Parameters
203
+ * None.
204
+ * @retval true No checks failed.
205
+ * @retval false At least one check failed.
206
+ */
207
+ [[nodiscard]] bool
208
+ was_successful (void) const noexcept;
209
+
210
+ protected:
211
+ /**
212
+ * @brief Total number of successful checks.
213
+ */
214
+ size_t successful_checks_ = 0;
215
+
216
+ /**
217
+ * @brief Total number of failed checks.
218
+ */
219
+ size_t failed_checks_ = 0;
220
+
221
+ /**
222
+ * @brief Total number of tests executed.
223
+ */
224
+ size_t executed_subtests_ = 0;
225
+ };
226
+
227
+ // ------------------------------------------------------------------------
228
+ } // namespace detail
229
+
230
+ // --------------------------------------------------------------------------
231
+ } // namespace micro_os_plus::micro_test_plus
232
+
233
+ #if defined(__GNUC__)
234
+ #pragma GCC diagnostic pop
235
+ #endif
236
+
237
+ // ----------------------------------------------------------------------------
238
+
239
+ #endif // __cplusplus
240
+
241
+ // ============================================================================
242
+ // Templates & constexpr implementations.
243
+
244
+ #include "inlines/runner-totals-inlines.h"
245
+
246
+ // ----------------------------------------------------------------------------
247
+
248
+ #endif // MICRO_TEST_PLUS_TEST_RUNNER_TOTALS_H_
249
+
250
+ // ----------------------------------------------------------------------------
@@ -0,0 +1,472 @@
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++ header file with declarations for the µTest++ test runner.
21
+ *
22
+ * @details
23
+ * This header provides the declarations for the test runner facilities used
24
+ * within the µTest++ framework. It defines the interface for managing the
25
+ * registration and execution of test suites, supporting automated discovery
26
+ * and orchestration of tests across a project.
27
+ *
28
+ * The test runner is responsible for initialising the test environment,
29
+ * registering test suites, managing command-line arguments, and determining
30
+ * the overall test result via an exit code. It also provides mechanisms for
31
+ * aborting test execution and retrieving the default suite name.
32
+ *
33
+ * All definitions reside within the
34
+ * `micro_os_plus::micro_test_plus` namespace, ensuring clear
35
+ * separation from user code and minimising the risk of naming conflicts.
36
+ *
37
+ * The header files are organised within the
38
+ * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
39
+ * modular codebase.
40
+ *
41
+ * This file is intended solely for internal use within the framework and
42
+ * should not be included directly by user code.
43
+ */
44
+
45
+ #ifndef MICRO_TEST_PLUS_TEST_RUNNER_H_
46
+ #define MICRO_TEST_PLUS_TEST_RUNNER_H_
47
+
48
+ // ----------------------------------------------------------------------------
49
+
50
+ #ifdef __cplusplus
51
+
52
+ // ----------------------------------------------------------------------------
53
+
54
+ #include <functional>
55
+ #include <memory>
56
+ #include <string>
57
+
58
+ #include "timings.h"
59
+ #include "test.h"
60
+ #include "reflection.h"
61
+
62
+ // ----------------------------------------------------------------------------
63
+
64
+ #if defined(__GNUC__)
65
+ #pragma GCC diagnostic push
66
+ #pragma GCC diagnostic ignored "-Wpadded"
67
+ #if defined(__clang__)
68
+ #pragma clang diagnostic ignored "-Wc++98-compat"
69
+ #else // GCC only
70
+ #pragma GCC diagnostic ignored "-Wsuggest-final-types"
71
+ #pragma GCC diagnostic ignored "-Wsuggest-final-methods"
72
+ #pragma GCC diagnostic ignored "-Wredundant-tags"
73
+ #endif
74
+ #endif
75
+
76
+ // ============================================================================
77
+
78
+ namespace micro_os_plus::micro_test_plus
79
+ {
80
+ // --------------------------------------------------------------------------
81
+
82
+ class suite;
83
+ class top_suite;
84
+ class reporter;
85
+
86
+ // ==========================================================================
87
+
88
+ /**
89
+ * @ingroup micro-test-plus-runners
90
+ * @brief The test runner for the µTest++ framework.
91
+ *
92
+ * @details
93
+ * The `runner` class is responsible for managing the registration and
94
+ * execution of test suites within the µTest++ framework. It maintains a
95
+ * collection of test suites, each of which registers itself automatically
96
+ * upon construction, enabling seamless integration and execution of tests
97
+ * across different components and folders of a project.
98
+ *
99
+ * The test runner provides methods for initialising the test environment,
100
+ * registering test suites, retrieving the runner's name, and determining the
101
+ * overall test result via an exit code. It also offers an abort mechanism
102
+ * for terminating test execution in exceptional circumstances.
103
+ *
104
+ * All members and methods are defined within the
105
+ * `micro_os_plus::micro_test_plus` namespace, ensuring clear separation from
106
+ * user code and minimising the risk of naming conflicts.
107
+ *
108
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
109
+ */
110
+ class runner : public detail::test_node
111
+ {
112
+ public:
113
+ /**
114
+ * @brief Constructor for the runner class.
115
+ *
116
+ * @par Parameters
117
+ * None.
118
+ */
119
+ runner (void);
120
+
121
+ /**
122
+ * @brief Deprecated constructor for the runner class.
123
+ *
124
+ * @param [in] top_suite_name The name given to the implicit top suite.
125
+ * Defaults to an empty string.
126
+ *
127
+ * @deprecated Use the anonymous constructor.
128
+ */
129
+ runner (const char* top_suite_name);
130
+
131
+ /**
132
+ * @brief Deleted copy constructor to prevent copying.
133
+ */
134
+ runner (const runner&) = delete;
135
+
136
+ /**
137
+ * @brief Deleted move constructor to prevent moving.
138
+ */
139
+ runner (runner&&) = delete;
140
+
141
+ /**
142
+ * @brief Deleted copy assignment operator to prevent copying.
143
+ */
144
+ runner&
145
+ operator= (const runner&)
146
+ = delete;
147
+
148
+ /**
149
+ * @brief Deleted move assignment operator to prevent moving.
150
+ */
151
+ runner&
152
+ operator= (runner&&)
153
+ = delete;
154
+
155
+ /**
156
+ * @brief Destructor for the runner class.
157
+ */
158
+ virtual ~runner () override;
159
+
160
+ /**
161
+ * @brief Initialises the test runner with command-line arguments.
162
+ *
163
+ * @param argc The argument count from main().
164
+ * @param argv The argument vector from main().
165
+ * @param top_suite_name The name given to the implicit top suite. Defaults
166
+ * to an empty string.
167
+ * @return Reference to the top-level test suite.
168
+ */
169
+ class suite&
170
+ initialise (int argc, char* argv[], const char* top_suite_name = "");
171
+
172
+ /**
173
+ * @brief Returns 0 if all tests were successful, 1 otherwise.
174
+ *
175
+ * @par Parameters
176
+ * None.
177
+ * @return Integer exit code representing the overall test result.
178
+ */
179
+ int
180
+ exit_code (void);
181
+
182
+ /**
183
+ * @brief Adds a test suite to the runner.
184
+ *
185
+ * @tparam Callable_T The type of a callable object.
186
+ * @tparam Args_T The types of the callable arguments.
187
+ *
188
+ * @param [in] name The test suite name or description, used in reports.
189
+ * @param [in] callable A generic callable object, usually a lambda,
190
+ * invoked to perform the test suite.
191
+ * @param [in] arguments A possibly empty list of arguments to be passed to
192
+ * the callable.
193
+ * @par Returns
194
+ * Nothing.
195
+ */
196
+ template <typename Callable_T, typename... Args_T>
197
+ void
198
+ suite (const char* name, Callable_T&& callable, Args_T&&... arguments);
199
+
200
+ // ------------------------------------------------------------------------
201
+
202
+ /**
203
+ * @brief Aborts test execution immediately.
204
+ *
205
+ * @param sl The source location from which the abort is triggered.
206
+ * @par Returns
207
+ * Nothing.
208
+ */
209
+ [[noreturn]] void
210
+ abort (const reflection::source_location& sl
211
+ = reflection::source_location::current ());
212
+
213
+ // ------------------------------------------------------------------------
214
+ // Getters.
215
+
216
+ /**
217
+ * @brief Returns the total count of registered test suites.
218
+ *
219
+ * @par Parameters
220
+ * None.
221
+ * @return The total number of test suites managed by this runner.
222
+ */
223
+ [[nodiscard]] virtual size_t
224
+ total_suites_count (void) const noexcept;
225
+
226
+ /**
227
+ * @brief Returns a reference to the test reporter.
228
+ *
229
+ * @par Parameters
230
+ * None.
231
+ * @return Reference to the test reporter.
232
+ */
233
+ [[nodiscard]] class reporter&
234
+ reporter (void) const noexcept;
235
+
236
+ /**
237
+ * @brief Gets the timings for this runner.
238
+ *
239
+ * @par Parameters
240
+ * None.
241
+ * @return A reference to the timestamps instance.
242
+ */
243
+ [[nodiscard]] detail::timestamps&
244
+ timings () noexcept;
245
+
246
+ /**
247
+ * @brief Gets the timings for this runner (const overload).
248
+ *
249
+ * @par Parameters
250
+ * None.
251
+ * @return A const reference to the timestamps instance.
252
+ */
253
+ [[nodiscard]] const detail::timestamps&
254
+ timings () const noexcept;
255
+
256
+ /**
257
+ * @brief Returns the count of test suites.
258
+ *
259
+ * @par Parameters
260
+ * None.
261
+ * @return The number of test suites, including the top one.
262
+ */
263
+ [[nodiscard]] size_t
264
+ suites_count (void) const noexcept;
265
+
266
+ protected:
267
+ /**
268
+ * @brief Runs all registered test suites.
269
+ *
270
+ * @par Parameters
271
+ * None.
272
+ */
273
+ virtual void
274
+ run_suites_ (void);
275
+
276
+ /**
277
+ * @brief Registers a test suite with the runner.
278
+ *
279
+ * @param [in] suite Owning pointer to the test suite to register.
280
+ * @par Returns
281
+ * Nothing.
282
+ */
283
+ void
284
+ register_suite_ (std::unique_ptr<class suite> suite);
285
+
286
+ // ------------------------------------------------------------------------
287
+ protected:
288
+ /**
289
+ * @brief The implicit top-level suite; always present and executed first.
290
+ */
291
+ class top_suite top_suite_;
292
+
293
+ /**
294
+ * @brief Owning collection of dynamically registered child suites.
295
+ *
296
+ * @details
297
+ * Each call to `runner::suite()` appends a new `suite` to this vector
298
+ * and runs it immediately. The vector retains ownership of all suites
299
+ * for the lifetime of the runner.
300
+ */
301
+ std::vector<std::unique_ptr<class suite>> children_suites_;
302
+
303
+ /**
304
+ * @brief Pointer to the test reporter used for outputting test results.
305
+ */
306
+ std::unique_ptr<class reporter> reporter_;
307
+
308
+ /**
309
+ * @brief Timings for this runner.
310
+ */
311
+ detail::timestamps timings_;
312
+
313
+ /**
314
+ * @brief Owned storage for the implicit top-suite name.
315
+ */
316
+ std::string top_suite_name_;
317
+ };
318
+
319
+ // ==========================================================================
320
+
321
+ /**
322
+ * @ingroup micro-test-plus-runners
323
+ * @brief A `runner` variant that also manages statically-registered test
324
+ * suites.
325
+ *
326
+ * @details
327
+ * `static_runner` extends `runner` to handle `static_suite` objects that
328
+ * are declared at namespace scope and therefore constructed before or after
329
+ * the runner itself, in unspecified static-initialisation order.
330
+ *
331
+ * The key design constraint is that `static_runner` instances must
332
+ * themselves be declared at namespace scope (in the BSS segment), so the
333
+ * pointer `static_children_suites_` is zero-initialised by the C runtime
334
+ * before any constructor runs. This ensures that `static_suite` objects
335
+ * constructed before `static_runner` can safely append themselves to the
336
+ * vector without losing registrations.
337
+ *
338
+ * During `exit_code()`, `run_suites_()` is called, which first runs all
339
+ * dynamically registered suites (base class behaviour) and then iterates
340
+ * over the statically registered suites.
341
+ *
342
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
343
+ */
344
+ class static_runner final : public runner
345
+ {
346
+ public:
347
+ /**
348
+ * @brief Constructor for the runner class.
349
+ *
350
+ * @par Parameters
351
+ * None.
352
+ */
353
+ static_runner (void);
354
+
355
+ /**
356
+ * @brief Constructs the static runner with a top-suite name.
357
+ *
358
+ * @param top_suite_name The name of the implicit top-level suite.
359
+ * Defaults to an empty string.
360
+ *
361
+ * @deprecated Use the anonymous constructor.
362
+ */
363
+ static_runner (const char* top_suite_name);
364
+
365
+ /**
366
+ * @brief Deleted copy constructor to prevent copying.
367
+ */
368
+ static_runner (const static_runner&) = delete;
369
+
370
+ /**
371
+ * @brief Deleted move constructor to prevent moving.
372
+ */
373
+ static_runner (static_runner&&) = delete;
374
+
375
+ /**
376
+ * @brief Deleted copy assignment operator to prevent copying.
377
+ */
378
+ static_runner&
379
+ operator= (const static_runner&)
380
+ = delete;
381
+
382
+ /**
383
+ * @brief Deleted move assignment operator to prevent moving.
384
+ */
385
+ static_runner&
386
+ operator= (static_runner&&)
387
+ = delete;
388
+
389
+ /**
390
+ * @brief Destructor for the static_runner class.
391
+ */
392
+ virtual ~static_runner () override;
393
+
394
+ // ------------------------------------------------------------------------
395
+
396
+ /**
397
+ * @brief Registers a static test suite with the runner.
398
+ *
399
+ * @param [in] runner The static runner instance.
400
+ * @param [in] suite The static test suite to register.
401
+ */
402
+ static void
403
+ register_static_suite (static_runner& runner, static_suite& suite);
404
+
405
+ /**
406
+ * @brief Returns the total count of registered static test suites.
407
+ *
408
+ * @par Parameters
409
+ * None.
410
+ * @return The total number of registered static test suites.
411
+ */
412
+ [[nodiscard]] size_t
413
+ static_suites_count (void) const noexcept;
414
+
415
+ /**
416
+ * @brief Returns the total count of all test suites, including static and
417
+ * dynamic.
418
+ *
419
+ * @par Parameters
420
+ * None.
421
+ * @return The total number of test suites.
422
+ */
423
+ [[nodiscard]] virtual size_t
424
+ total_suites_count (void) const noexcept final override;
425
+
426
+ protected:
427
+ /**
428
+ * @brief Runs all child suites, including statically registered ones.
429
+ *
430
+ * @par Parameters
431
+ * None.
432
+ */
433
+ void
434
+ run_suites_ (void) override;
435
+
436
+ protected:
437
+ /**
438
+ * @brief Pointer to the vector of registered static test suites.
439
+ *
440
+ * `static_runner` instances are always declared at namespace scope,
441
+ * so this pointer lives in the BSS segment and is zero-initialised
442
+ * before any constructor runs. This guarantees that static test suites
443
+ * registered before this runner's constructor executes (due to
444
+ * unspecified static initialisation order across translation units)
445
+ * are not lost. The pointer MUST NOT carry an explicit
446
+ * default member initialiser, as that would run during construction
447
+ * and could overwrite a value already set by an earlier-constructed
448
+ * `static_suite`.
449
+ */
450
+ std::vector<static_suite*>* static_children_suites_;
451
+ };
452
+
453
+ } // namespace micro_os_plus::micro_test_plus
454
+
455
+ #if defined(__GNUC__)
456
+ #pragma GCC diagnostic pop
457
+ #endif
458
+
459
+ // ----------------------------------------------------------------------------
460
+
461
+ #endif // __cplusplus
462
+
463
+ // ============================================================================
464
+ // Templates & constexpr implementations.
465
+
466
+ #include "inlines/runner-inlines.h"
467
+
468
+ // ----------------------------------------------------------------------------
469
+
470
+ #endif // MICRO_TEST_PLUS_TEST_RUNNER_H_
471
+
472
+ // ----------------------------------------------------------------------------