@micro-os-plus/micro-test-plus 3.2.2 → 3.2.3

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 (41) hide show
  1. package/.cmake-format.yaml +11 -0
  2. package/CHANGELOG.md +352 -2
  3. package/CMakeLists.txt +32 -30
  4. package/LICENSE +1 -1
  5. package/README.md +1 -1
  6. package/{xcdl.json → config/xcdl-build.json} +6 -6
  7. package/include/micro-os-plus/micro-test-plus/detail.h +1885 -0
  8. package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
  9. package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
  10. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
  11. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
  12. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
  15. package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +471 -0
  16. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
  17. package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
  18. package/include/micro-os-plus/micro-test-plus/math.h +217 -0
  19. package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
  20. package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
  21. package/include/micro-os-plus/micro-test-plus/test-reporter.h +801 -0
  22. package/include/micro-os-plus/micro-test-plus/test-runner.h +241 -0
  23. package/include/micro-os-plus/micro-test-plus/test-suite.h +456 -0
  24. package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
  25. package/include/micro-os-plus/micro-test-plus.h +169 -551
  26. package/meson.build +5 -5
  27. package/package.json +29 -34
  28. package/src/micro-test-plus.cpp +131 -35
  29. package/src/test-reporter.cpp +348 -6
  30. package/src/test-runner.cpp +69 -5
  31. package/src/test-suite.cpp +124 -5
  32. package/include/micro-os-plus/detail.h +0 -765
  33. package/include/micro-os-plus/inlines.h +0 -209
  34. package/include/micro-os-plus/literals.h +0 -512
  35. package/include/micro-os-plus/math.h +0 -204
  36. package/include/micro-os-plus/reflection.h +0 -139
  37. package/include/micro-os-plus/test-reporter-inlines.h +0 -230
  38. package/include/micro-os-plus/test-reporter.h +0 -356
  39. package/include/micro-os-plus/test-runner.h +0 -132
  40. package/include/micro-os-plus/test-suite.h +0 -306
  41. package/include/micro-os-plus/type-traits.h +0 -389
@@ -1,18 +1,55 @@
1
1
  /*
2
2
  * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
- * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
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
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/mit.
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
10
  *
11
11
  * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
12
  * released under the terms of the Boost Version 1.0 Software License,
13
13
  * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
14
  */
15
15
 
16
+ // ----------------------------------------------------------------------------
17
+
18
+ /**
19
+ * @file
20
+ * @brief Main C++ header with the declarations for the µTest++ Testing
21
+ * Framework.
22
+ *
23
+ * @details
24
+ * This header serves as the principal entry point for the µTest++ testing
25
+ * framework, purpose-built for both embedded and general C++ projects.
26
+ *
27
+ * It provides all essential declarations required to write and manage tests,
28
+ * including test runner and reporter objects, test suite and test case
29
+ * management, expectations, assumptions, comparators, logical operators,
30
+ * exception verification, and utility functions.
31
+ *
32
+ * The header also incorporates all necessary dependencies and internal headers
33
+ * to ensure the framework operates correctly and efficiently.
34
+ *
35
+ * All public API definitions reside within the
36
+ * `micro_os_plus::micro_test_plus` namespace and its nested namespaces,
37
+ * ensuring clear separation from user code and minimising the risk of naming
38
+ * conflicts.
39
+ *
40
+ * This file is located in the top-level `include/micro-os-plus` directory; all
41
+ * other header files are organised within the
42
+ * `include/micro-os-plus/micro-test-plus` directory to maintain a structured
43
+ * and modular codebase.
44
+ *
45
+ * To access the complete functionality of the µTest++ framework, users should
46
+ * include this header in their test projects.
47
+ *
48
+ * The implementation is significantly inspired by Boost UT, with adaptations
49
+ * and extensions to address the requirements of embedded development and the
50
+ * µTest++ framework.
51
+ */
52
+
16
53
  #ifndef MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
17
54
  #define MICRO_TEST_PLUS_MICRO_TEST_PLUS_H_
18
55
 
@@ -26,14 +63,19 @@
26
63
  #include <micro-os-plus/config.h>
27
64
  #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
28
65
 
29
- #include "reflection.h"
30
- #include "math.h"
31
- #include "type-traits.h"
32
- #include "literals.h"
33
- #include "test-suite.h"
34
- #include "test-runner.h"
35
- #include "test-reporter.h"
36
- #include "detail.h"
66
+ #include "micro-test-plus/type-traits.h"
67
+ #include "micro-test-plus/reflection.h"
68
+
69
+ #include "micro-test-plus/detail.h"
70
+
71
+ #include "micro-test-plus/math.h"
72
+ #include "micro-test-plus/literals.h"
73
+ #include "micro-test-plus/function-comparators.h"
74
+ #include "micro-test-plus/operators.h"
75
+
76
+ #include "micro-test-plus/test-suite.h"
77
+ #include "micro-test-plus/test-runner.h"
78
+ #include "micro-test-plus/test-reporter.h"
37
79
 
38
80
  // ----------------------------------------------------------------------------
39
81
 
@@ -48,6 +90,30 @@
48
90
  #endif
49
91
  #endif
50
92
 
93
+ /**
94
+ * @namespace micro_os_plus::micro_test_plus
95
+ * @brief Primary namespace for the µTest++ testing framework.
96
+ *
97
+ * @details
98
+ * The `micro_os_plus::micro_test_plus` namespace encapsulates all core
99
+ * components, types, and utilities of the µTest++ testing framework, providing
100
+ * a dedicated scope for its public API.
101
+ *
102
+ * This namespace is structured into several nested namespaces, each
103
+ * responsible for a specific aspect of the framework, such as mathematical
104
+ * utilities, type traits, literals, test suite and test case management, test
105
+ * runners, test reporters, internal details, operators, and utility functions.
106
+ *
107
+ * By grouping all definitions within this namespace and its sub-namespaces,
108
+ * the framework achieves clear code organisation, minimises naming conflicts,
109
+ * and enhances maintainability. This modular structure supports robust,
110
+ * scalable, and professional test development for both embedded and general
111
+ * C++ projects.
112
+ *
113
+ * All public API definitions are implemented in the `include/micro-os-plus`
114
+ * folder, ensuring a clear separation from user code and facilitating
115
+ * straightforward integration with the wider µOS++ ecosystem.
116
+ */
51
117
  namespace micro_os_plus::micro_test_plus
52
118
  {
53
119
  // --------------------------------------------------------------------------
@@ -61,10 +127,12 @@ namespace micro_os_plus::micro_test_plus
61
127
 
62
128
  /**
63
129
  * @ingroup micro-test-plus-inits
64
- * @brief Initialize the test framework.
65
- * @param [in] argc The number of arguments.
66
- * @param [in] argv Array of pointers to null terminated arguments.
67
- * @param [in] name The name of the default test suite.
130
+ * @brief Initialise the µTest++ framework.
131
+ *
132
+ * @param [in] argc The number of command-line arguments.
133
+ * @param [in] argv Array of pointers to null-terminated argument strings.
134
+ * @param [in] name The name of the default test suite. Defaults to `"Main"`
135
+ * if not specified.
68
136
  * @par Returns
69
137
  * Nothing.
70
138
  */
@@ -73,10 +141,11 @@ namespace micro_os_plus::micro_test_plus
73
141
 
74
142
  /**
75
143
  * @ingroup micro-test-plus-inits
76
- * @brief Complete the test and return the exit code.
144
+ * @brief Complete the test run and return the exit code.
145
+ *
77
146
  * @par Parameters
78
- * None.
79
- * @return 0 for success, 1 for failure.
147
+ * None.
148
+ * @return 0 if all tests were successful, 1 if any test failed.
80
149
  */
81
150
  [[nodiscard]] int
82
151
  exit_code (void);
@@ -84,14 +153,15 @@ namespace micro_os_plus::micro_test_plus
84
153
  /**
85
154
  * @ingroup micro-test-plus-test-case
86
155
  * @brief Define and execute a test case.
87
- * @tparam Callable_T The type of an object that can be called.
88
- * @tparam Args_T The type of the callable arguments.
89
- * @param [in] name The test case name or description.
90
- * A short string used in the report.
91
- * @param [in] callable A generic callable object,
92
- * invoked to perform the test. Usually a lambda.
93
- * @param [in] arguments A possibly empty list of arguments to be
94
- * passed to the callable.
156
+ *
157
+ * @tparam Callable_T The type of the callable object to be executed as the
158
+ * test case.
159
+ * @tparam Args_T The types of the arguments to be passed to the callable.
160
+ * @param [in] name The test case name or description, used in test reports.
161
+ * @param [in] callable A generic callable object, usually a lambda, invoked
162
+ * to perform the test.
163
+ * @param [in] arguments A possibly empty list of arguments to be passed to
164
+ * the callable.
95
165
  * @par Returns
96
166
  * Nothing.
97
167
  */
@@ -102,34 +172,17 @@ namespace micro_os_plus::micro_test_plus
102
172
  /**
103
173
  * @ingroup micro-test-plus-expectations
104
174
  * @brief Evaluate a generic condition and report the results.
175
+ *
105
176
  * @tparam Expr_T The type of the custom expression.
177
+ *
178
+ * @par SFINAE
179
+ * Enabled only if `Expr_T` is derived from `detail::op` or
180
+ * is convertible to `bool`.
181
+ *
182
+
106
183
  * @param [in] expr Logical expression to evaluate.
107
- * @param [in] sl Optional source location, by default the current line.
184
+ * @param [in] sl Optional source location, defaulting to the current line.
108
185
  * @return An output stream to write optional messages.
109
- *
110
- * @details
111
- * The expression can be any logical expression, but, in order to
112
- * allow the framework to help identify the reason why the check failed
113
- * (by displaying the actual vs. the expected values), the expression
114
- * should use the provided `eq()`, `ne()`, `lt()`, `le()`, `gt()`, `ge()`
115
- * comparators, or, if the custom operators namespace is included,
116
- * to use the custom type operands.
117
- *
118
- * The function template can be used only for expressions that evaluate to
119
- * a boolean or use custom comparators/operators derived from the
120
- * local `detail::op` type.
121
- *
122
- * For generic checks performed with standard C/C++
123
- *`if` statements outside the `expect()` logical expression
124
- * (like complex `try`/`catch` statements),
125
- * the results can be reported with `expect(true)` or `expect(false)`.
126
- *
127
- * @par Example
128
- * ```cpp
129
- * namespace mt = micro_os_plus::micro_test_plus;
130
- *
131
- * mt::expect (compute_answer () == 42) << "answer is 42";
132
- * ```
133
186
  */
134
187
  template <class Expr_T, type_traits::requires_t<
135
188
  type_traits::is_op_v<Expr_T>
@@ -137,29 +190,21 @@ namespace micro_os_plus::micro_test_plus
137
190
  = 0>
138
191
  constexpr auto
139
192
  expect (const Expr_T& expr, const reflection::source_location& sl
140
- = reflection::source_location::current ())
141
- {
142
- return detail::deferred_reporter<Expr_T>{ expr, false, sl };
143
- }
193
+ = reflection::source_location::current ());
144
194
 
145
195
  /**
146
196
  * @ingroup micro-test-plus-assumptions
147
- * @brief Check a condition and, if false, abort.
148
- * @tparam Expr_T The type of the custom expression.
149
- * @param [in] expr Logical expression to evaluate.
150
- * @param [in] sl Optional source location, by default the current line.
151
- * @return An output stream to write optional messages.
197
+ * @brief Check a condition and, if false, abort test execution.
152
198
  *
153
- * The template is usable only for expressions that evaluate to
154
- * a boolean or use custom comparators/operators derived from the
155
- * local `detail::op` type.
199
+ * @tparam Expr_T The type of the custom expression.
156
200
  *
157
- * @par Example
158
- * ```cpp
159
- * namespace mt = micro_os_plus::micro_test_plus;
201
+ * @par SFINAE
202
+ * Enabled only if `Expr_T` is derived from `detail::op` or
203
+ * is convertible to `bool`.
160
204
  *
161
- * mt::assume (compute_answer () == 42) << "answer is 42";
162
- * ```
205
+ * @param [in] expr Logical expression to evaluate.
206
+ * @param [in] sl Optional source location, defaulting to the current line.
207
+ * @return An output stream to write optional messages.
163
208
  */
164
209
  template <class Expr_T, type_traits::requires_t<
165
210
  type_traits::is_op_v<Expr_T>
@@ -167,522 +212,83 @@ namespace micro_os_plus::micro_test_plus
167
212
  = 0>
168
213
  constexpr auto
169
214
  assume (const Expr_T& expr, const reflection::source_location& sl
170
- = reflection::source_location::current ())
171
- {
172
- return detail::deferred_reporter<Expr_T>{ expr, true, sl };
173
- }
215
+ = reflection::source_location::current ());
174
216
 
175
217
  // --------------------------------------------------------------------------
176
218
 
177
219
  #if defined(__cpp_exceptions)
220
+
178
221
  /**
179
222
  * @ingroup micro-test-plus-exceptions
180
223
  * @brief Check if a callable throws a specific exception.
181
- * @tparam Exception_T Type of the exception.
182
- * @tparam Callable_T The type of an object that can be called.
183
- * @param [in] func Function to check.
224
+ *
225
+ * @tparam Exception_T The type of the exception expected to be thrown.
226
+ * @tparam Callable_T The type of the callable object to be invoked.
227
+ * @param [in] func The callable object to check for exception throwing
228
+ * behaviour.
184
229
  * @return An output stream to write optional messages.
185
230
  */
186
231
  template <class Exception_T, class Callable_T>
187
232
  [[nodiscard]] constexpr auto
188
- throws (const Callable_T& func)
189
- {
190
- return detail::throws_<Callable_T, Exception_T>{ func };
191
- }
233
+ throws (const Callable_T& func);
192
234
 
193
235
  /**
194
236
  * @ingroup micro-test-plus-exceptions
195
237
  * @brief Check if a callable throws an exception (any exception).
196
- * @tparam Callable_T The type of an object that can be called.
197
- * @param [in] func Function to check.
238
+ *
239
+ * @tparam Callable_T The type of the callable object to be invoked.
240
+ * @param [in] func The callable object to check for exception throwing
241
+ * behaviour.
198
242
  * @return An output stream to write optional messages.
199
243
  */
200
244
  template <class Callable_T>
201
245
  [[nodiscard]] constexpr auto
202
- throws (const Callable_T& func)
203
- {
204
- return detail::throws_<Callable_T>{ func };
205
- }
246
+ throws (const Callable_T& func);
206
247
 
207
248
  /**
208
249
  * @ingroup micro-test-plus-exceptions
209
- * @brief Check if a callable doesn't throw an exception.
210
- * @tparam Callable_T The type of an object that can be called.
211
- * @param [in] func Function to check.
250
+ * @brief Check if a callable does not throw an exception.
251
+ *
252
+ * @tparam Callable_T The type of the callable object to be invoked.
253
+ * @param [in] func The callable object to check for exception safety.
212
254
  * @return An output stream to write optional messages.
213
255
  */
214
256
  template <class Callable_T>
215
257
  [[nodiscard]] constexpr auto
216
- nothrow (const Callable_T& func)
217
- {
218
- return detail::nothrow_{ func };
219
- }
258
+ nothrow (const Callable_T& func);
259
+
220
260
  #endif
221
261
 
222
262
  // --------------------------------------------------------------------------
223
263
 
224
264
  /**
225
- * @ingroup micro-test-plus-function-comparators
226
- * @brief Generic equality comparator. Matches any
227
- * non-pointer type.
228
- * @tparam Lhs_T Type of the left hand side operand.
229
- * @tparam Rhs_T Type of the right hand side operand.
230
- * @param [in] lhs Left hand side operand.
231
- * @param [in] rhs Right hand side operand.
232
- * @return True if the operands are equal.
233
- */
234
- template <class Lhs_T, class Rhs_T>
235
- [[nodiscard]] constexpr auto
236
- eq (const Lhs_T& lhs, const Rhs_T& rhs)
237
- {
238
- return detail::eq_{ lhs, rhs };
239
- }
240
-
241
- /**
242
- * @ingroup micro-test-plus-function-comparators
243
- * @brief Pointer equality comparator. Matches pointers
244
- * to any types.
245
- * @tparam Lhs_T Type of the left hand side operand.
246
- * @tparam Rhs_T Type of the right hand side operand.
247
- * @param [in] lhs Left hand side operand.
248
- * @param [in] rhs Right hand side operand.
249
- * @return True if the pointers are equal.
250
- */
251
- template <class Lhs_T, class Rhs_T>
252
- [[nodiscard]] constexpr auto
253
- eq (Lhs_T* lhs, Rhs_T* rhs)
254
- {
255
- return detail::eq_{ lhs, rhs };
256
- }
257
-
258
- /**
259
- * @ingroup micro-test-plus-function-comparators
260
- * @brief Generic non-equality comparator.
261
- * @tparam Lhs_T Type of the left hand side operand.
262
- * @tparam Rhs_T Type of the right hand side operand.
263
- * @param [in] lhs Left hand side operand.
264
- * @param [in] rhs Right hand side operand.
265
- * @return True if the operands are not equal.
266
- */
267
- template <class Lhs_T, class Rhs_T>
268
- [[nodiscard]] constexpr auto
269
- ne (const Lhs_T& lhs, const Rhs_T& rhs)
270
- {
271
- return detail::ne_{ lhs, rhs };
272
- }
273
-
274
- /**
275
- * @ingroup micro-test-plus-function-comparators
276
- * @brief Pointer non-equality comparator.
277
- * @tparam Lhs_T Type of the left hand side operand.
278
- * @tparam Rhs_T Type of the right hand side operand.
279
- * @param [in] lhs Left hand side operand.
280
- * @param [in] rhs Right hand side operand.
281
- * @return True if the pointers are not equal.
282
- */
283
- template <class Lhs_T, class Rhs_T>
284
- [[nodiscard]] constexpr auto
285
- ne (Lhs_T* lhs, Rhs_T* rhs)
286
- {
287
- return detail::ne_{ lhs, rhs };
288
- }
289
-
290
- /**
291
- * @ingroup micro-test-plus-function-comparators
292
- * @brief Generic greater than comparator.
293
- * @tparam Lhs_T Type of the left hand side operand.
294
- * @tparam Rhs_T Type of the right hand side operand.
295
- * @param [in] lhs Left hand side operand.
296
- * @param [in] rhs Right hand side operand.
297
- * @return True if lhs > rhs.
298
- */
299
- template <class Lhs_T, class Rhs_T>
300
- [[nodiscard]] constexpr auto
301
- gt (const Lhs_T& lhs, const Rhs_T& rhs)
302
- {
303
- return detail::gt_{ lhs, rhs };
304
- }
305
-
306
- /**
307
- * @ingroup micro-test-plus-function-comparators
308
- * @brief Pointer greater than comparator.
309
- * @tparam Lhs_T Type of the left hand side operand.
310
- * @tparam Rhs_T Type of the right hand side operand.
311
- * @param [in] lhs Left hand side operand.
312
- * @param [in] rhs Right hand side operand.
313
- * @return True if the lhs pointer > rhs pointer.
314
- */
315
- template <class Lhs_T, class Rhs_T>
316
- [[nodiscard]] constexpr auto
317
- gt (Lhs_T* lhs, Rhs_T* rhs)
318
- {
319
- return detail::gt_{ lhs, rhs };
320
- }
321
-
322
- /**
323
- * @ingroup micro-test-plus-function-comparators
324
- * @brief Generic greater than or equal comparator.
325
- * @tparam Lhs_T Type of the left hand side operand.
326
- * @tparam Rhs_T Type of the right hand side operand.
327
- * @param [in] lhs Left hand side operand.
328
- * @param [in] rhs Right hand side operand.
329
- * @return True if lhs >= rhs.
330
- */
331
- template <class Lhs_T, class Rhs_T>
332
- [[nodiscard]] constexpr auto
333
- ge (const Lhs_T& lhs, const Rhs_T& rhs)
334
- {
335
- return detail::ge_{ lhs, rhs };
336
- }
337
-
338
- /**
339
- * @ingroup micro-test-plus-function-comparators
340
- * @brief Pointer greater than or equal comparator.
341
- * @tparam Lhs_T Type of the left hand side operand.
342
- * @tparam Rhs_T Type of the right hand side operand.
343
- * @param [in] lhs Left hand side operand.
344
- * @param [in] rhs Right hand side operand.
345
- * @return True if the lhs pointer >= rhs pointer.
346
- */
347
- template <class Lhs_T, class Rhs_T>
348
- [[nodiscard]] constexpr auto
349
- ge (Lhs_T* lhs, Rhs_T* rhs)
350
- {
351
- return detail::ge_{ lhs, rhs };
352
- }
353
-
354
- /**
355
- * @ingroup micro-test-plus-function-comparators
356
- * @brief Generic less than comparator.
357
- * @tparam Lhs_T Type of the left hand side operand.
358
- * @tparam Rhs_T Type of the right hand side operand.
359
- * @param [in] lhs Left hand side operand.
360
- * @param [in] rhs Right hand side operand.
361
- * @return True if lhs < rhs.
362
- */
363
- template <class Lhs_T, class Rhs_T>
364
- [[nodiscard]] constexpr auto
365
- lt (const Lhs_T& lhs, const Rhs_T& rhs)
366
- {
367
- return detail::lt_{ lhs, rhs };
368
- }
369
-
370
- /**
371
- * @ingroup micro-test-plus-function-comparators
372
- * @brief Generic less than comparator.
373
- * @tparam Lhs_T Type of the left hand side operand.
374
- * @tparam Rhs_T Type of the right hand side operand.
375
- * @param [in] lhs Left hand side operand.
376
- * @param [in] rhs Right hand side operand.
377
- * @return True if the lhs pointer < rhs pointer.
378
- */
379
- template <class Lhs_T, class Rhs_T>
380
- [[nodiscard]] constexpr auto
381
- lt (Lhs_T* lhs, Rhs_T* rhs)
382
- {
383
- return detail::lt_{ lhs, rhs };
384
- }
385
-
386
- /**
387
- * @ingroup micro-test-plus-function-comparators
388
- * @brief Generic less than or equal comparator.
389
- * @tparam Lhs_T Type of the left hand side operand.
390
- * @tparam Rhs_T Type of the right hand side operand.
391
- * @param [in] lhs Left hand side operand.
392
- * @param [in] rhs Right hand side operand.
393
- * @return True if lhs <= rhs.
394
- */
395
- template <class Lhs_T, class Rhs_T>
396
- [[nodiscard]] constexpr auto
397
- le (const Lhs_T& lhs, const Rhs_T& rhs)
398
- {
399
- return detail::le_{ lhs, rhs };
400
- }
401
-
402
- /**
403
- * @ingroup micro-test-plus-function-comparators
404
- * @brief Generic less than or equal comparator.
405
- * @tparam Lhs_T Type of the left hand side operand.
406
- * @tparam Rhs_T Type of the right hand side operand.
407
- * @param [in] lhs Left hand side operand.
408
- * @param [in] rhs Right hand side operand.
409
- * @return True if the lhs pointer <= rhs pointer.
410
- */
411
- template <class Lhs_T, class Rhs_T>
412
- [[nodiscard]] constexpr auto
413
- le (Lhs_T* lhs, Rhs_T* rhs)
414
- {
415
- return detail::le_{ lhs, rhs };
416
- }
417
-
418
- /**
419
- * @ingroup micro-test-plus-logical-functions
420
- * @brief Generic logical **not**.
421
- * @tparam Expr_T Type of the operand.
422
- * @param [in] expr Logical expression.
423
- * @return True if the operand is false.
424
- *
425
- * @note
426
- * The underscore is intentional,
427
- * to differentiate from the standard operator.
428
- */
429
- template <class Expr_T>
430
- [[nodiscard]] constexpr auto
431
- _not (const Expr_T& expr)
432
- {
433
- return detail::not_{ expr };
434
- }
435
-
436
- /**
437
- * @ingroup micro-test-plus-logical-functions
438
- * @brief Generic logical **and**.
439
- * @tparam Lhs_T Type of the left hand side operand.
440
- * @tparam Rhs_T Type of the right hand side operand.
441
- * @param [in] lhs Left hand side operand.
442
- * @param [in] rhs Right hand side operand.
443
- * @return True if both operand expressions are true.
265
+ * @namespace micro_os_plus::micro_test_plus::utility
266
+ * @brief Utility functions for the µTest++ testing framework.
444
267
  *
445
- * @note
446
- * The underscore is intentional,
447
- * to differentiate from the standard operator.
448
- */
449
- template <class Lhs_T, class Rhs_T>
450
- [[nodiscard]] constexpr auto
451
- _and (const Lhs_T& lhs, const Rhs_T& rhs)
452
- {
453
- return detail::and_{ lhs, rhs };
454
- }
455
-
456
- /**
457
- * @ingroup micro-test-plus-logical-functions
458
- * @brief Generic logical **or**.
459
- * @tparam Lhs_T Type of the left hand side operand.
460
- * @tparam Rhs_T Type of the right hand side operand.
461
- * @param [in] lhs Left hand side operand.
462
- * @param [in] rhs Right hand side operand.
463
- * @return True if at least one of the operand expressions is true.
464
- *
465
- * @note
466
- * The underscore is intentional,
467
- * to differentiate from the standard operator.
468
- */
469
- template <class Lhs_T, class Rhs_T>
470
- [[nodiscard]] constexpr auto
471
- _or (const Lhs_T& lhs, const Rhs_T& rhs)
472
- {
473
- return detail::or_{ lhs, rhs };
474
- }
475
-
476
- /**
477
- * @brief Generic mutator, to remove const from any type.
478
- */
479
- template <class T>
480
- [[nodiscard]] constexpr auto
481
- mut (const T& t) noexcept -> T&
482
- {
483
- return const_cast<T&> (t);
484
- }
485
-
486
- // --------------------------------------------------------------------------
487
-
488
- /**
489
- * @brief Separate namespace with custom operators.
268
+ * @details
269
+ * The `micro_os_plus::micro_test_plus::utility` namespace provides a suite
270
+ * of helper functions designed to support advanced string operations and
271
+ * other common tasks within the µTest++ framework.
490
272
  *
491
- * @warning Please note that they
492
- * may interfere with other operators existing in the tested application.
273
+ * These utilities include functions for pattern matching—such as verifying
274
+ * whether a string matches a specified pattern—and for splitting strings
275
+ * into sub-strings based on delimiters. The implementations are efficient
276
+ * and suitable for both embedded and general C++ projects.
493
277
  *
494
- * To minimise the interferences, these operators are recognised only
495
- * for specific types, and generally require constants to be
496
- * suffixed with literals (like `1_i`), and dynamic values to be
497
- * casted to the custom types (like `_i(...)`).
278
+ * By encapsulating these helper functions within a dedicated namespace, the
279
+ * framework maintains clear code organisation and minimises naming
280
+ * conflicts.
498
281
  */
499
- namespace operators
500
- {
501
- /**
502
- * @ingroup micro-test-plus-string-operators
503
- * @brief Equality operator for `string_view` objects.
504
- */
505
- [[nodiscard]] constexpr auto
506
- operator== (std::string_view lhs, std::string_view rhs)
507
- {
508
- return detail::eq_{ lhs, rhs };
509
- }
510
-
511
- /**
512
- * @ingroup micro-test-plus-string-operators
513
- * @brief Non-equality operator for `string_view` objects.
514
- */
515
- [[nodiscard]] constexpr auto
516
- operator!= (std::string_view lhs, std::string_view rhs)
517
- {
518
- return detail::ne_{ lhs, rhs };
519
- }
520
-
521
- /**
522
- * @ingroup micro-test-plus-container-operators
523
- * @brief Equality operator for containers.
524
- */
525
- template <class T,
526
- type_traits::requires_t<type_traits::is_container_v<T>> = 0>
527
- [[nodiscard]] constexpr auto
528
- operator== (T&& lhs, T&& rhs)
529
- {
530
- return detail::eq_{ static_cast<T&&> (lhs), static_cast<T&&> (rhs) };
531
- }
532
-
533
- /**
534
- * @ingroup micro-test-plus-container-operators
535
- * @brief Non-equality operator for containers.
536
- */
537
- template <class T,
538
- type_traits::requires_t<type_traits::is_container_v<T>> = 0>
539
- [[nodiscard]] constexpr auto
540
- operator!= (T&& lhs, T&& rhs)
541
- {
542
- return detail::ne_{ static_cast<T&&> (lhs), static_cast<T&&> (rhs) };
543
- }
544
-
545
- /**
546
- * @ingroup micro-test-plus-operators
547
- * @brief Equality operator. It matches only if at least one
548
- * operand is of local type (derived from local `op`).
549
- */
550
- template <class Lhs_T, class Rhs_T,
551
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
552
- or type_traits::is_op_v<Rhs_T>>
553
- = 0>
554
- [[nodiscard]] constexpr auto
555
- operator== (const Lhs_T& lhs, const Rhs_T& rhs)
556
- {
557
- return detail::eq_{ lhs, rhs };
558
- }
559
-
560
- /**
561
- * @ingroup micro-test-plus-operators
562
- * @brief Non-equality operator. It matches only if at least one
563
- * operand is of local type (derived from local `op`).
564
- */
565
- template <class Lhs_T, class Rhs_T,
566
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
567
- or type_traits::is_op_v<Rhs_T>>
568
- = 0>
569
- [[nodiscard]] constexpr auto
570
- operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
571
- {
572
- return detail::ne_{ lhs, rhs };
573
- }
574
-
575
- /**
576
- * @ingroup micro-test-plus-operators
577
- * @brief Greater than operator. It matches only if at least one
578
- * operand is of local type (derived from local `op`).
579
- */
580
- template <class Lhs_T, class Rhs_T,
581
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
582
- or type_traits::is_op_v<Rhs_T>>
583
- = 0>
584
- [[nodiscard]] constexpr auto
585
- operator> (const Lhs_T& lhs, const Rhs_T& rhs)
586
- {
587
- return detail::gt_{ lhs, rhs };
588
- }
589
-
590
- /**
591
- * @ingroup micro-test-plus-operators
592
- * @brief Greater than or equal operator. It matches only if at least one
593
- * operand is of local type (derived from local `op`).
594
- */
595
- template <class Lhs_T, class Rhs_T,
596
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
597
- or type_traits::is_op_v<Rhs_T>>
598
- = 0>
599
- [[nodiscard]] constexpr auto
600
- operator>= (const Lhs_T& lhs, const Rhs_T& rhs)
601
- {
602
- return detail::ge_{ lhs, rhs };
603
- }
604
-
605
- /**
606
- * @ingroup micro-test-plus-operators
607
- * @brief Less than operator. It matches only if at least one
608
- * operand is of local type (derived from local `op`).
609
- */
610
- template <class Lhs_T, class Rhs_T,
611
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
612
- or type_traits::is_op_v<Rhs_T>>
613
- = 0>
614
- [[nodiscard]] constexpr auto
615
- operator< (const Lhs_T& lhs, const Rhs_T& rhs)
616
- {
617
- return detail::lt_{ lhs, rhs };
618
- }
619
-
620
- /**
621
- * @ingroup micro-test-plus-operators
622
- * @brief Less than or equal operator. It matches only if at least one
623
- * operand is of local type (derived from local `op`).
624
- */
625
- template <class Lhs_T, class Rhs_T,
626
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
627
- or type_traits::is_op_v<Rhs_T>>
628
- = 0>
629
- [[nodiscard]] constexpr auto
630
- operator<= (const Lhs_T& lhs, const Rhs_T& rhs)
631
- {
632
- return detail::le_{ lhs, rhs };
633
- }
634
-
635
- /**
636
- * @ingroup micro-test-plus-operators
637
- * @brief Logical `&&` (and) operator. It matches only if at least one
638
- * operand is of local type (derived from local `op`).
639
- */
640
- template <class Lhs_T, class Rhs_T,
641
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
642
- or type_traits::is_op_v<Rhs_T>>
643
- = 0>
644
- [[nodiscard]] constexpr auto
645
- operator and (const Lhs_T& lhs, const Rhs_T& rhs)
646
- {
647
- return detail::and_{ lhs, rhs };
648
- }
649
-
650
- /**
651
- * @ingroup micro-test-plus-operators
652
- * @brief Logical `||` (or) operator. It matches only if at least one
653
- * operand is of local type (derived from local `op`).
654
- */
655
- template <class Lhs_T, class Rhs_T,
656
- type_traits::requires_t<type_traits::is_op_v<Lhs_T>
657
- or type_traits::is_op_v<Rhs_T>>
658
- = 0>
659
- [[nodiscard]] constexpr auto
660
- operator or (const Lhs_T& lhs, const Rhs_T& rhs)
661
- {
662
- return detail::or_{ lhs, rhs };
663
- }
664
-
665
- /**
666
- * @ingroup micro-test-plus-operators
667
- * @brief Logical `!` (not) operator. It matches only if the
668
- * operand is of local type (derived from local `op`).
669
- */
670
- template <class T, type_traits::requires_t<type_traits::is_op_v<T>> = 0>
671
- [[nodiscard]] constexpr auto
672
- operator not(const T& t)
673
- {
674
- return detail::not_{ t };
675
- }
676
- } // namespace operators
677
-
678
282
  namespace utility
679
283
  {
680
284
  /**
681
285
  * @ingroup micro-test-plus-utility-functions
682
286
  * @brief Check if a string matches a pattern.
683
- * @param [in] input String view to check.
684
- * @param [in] pattern Sting view with the pattern.
685
- * @return True if the string matches the pattern.
287
+ *
288
+ * @param [in] input The string view to be checked.
289
+ * @param [in] pattern The string view containing the pattern to match.
290
+ * @return `true` if the input string matches the pattern; otherwise,
291
+ * `false`.
686
292
  */
687
293
  [[nodiscard]] bool
688
294
  is_match (std::string_view input, std::string_view pattern);
@@ -690,16 +296,19 @@ namespace micro_os_plus::micro_test_plus
690
296
  /**
691
297
  * @ingroup micro-test-plus-utility-functions
692
298
  * @brief Split a string into a vector of sub-strings.
299
+ *
693
300
  * @tparam T Type of the input string.
694
301
  * @tparam Delim_T Type of the delimiter.
302
+ *
695
303
  * @param [in] input Input string to split.
696
304
  * @param [in] delim Delimiter string.
697
- * @return An array of strings.
305
+ * @return A vector containing the resulting sub-strings.
698
306
  */
699
307
  template <class T, class Delim_T>
700
308
  [[nodiscard]] auto
701
309
  split (T input, Delim_T delim) -> std::vector<T>;
702
310
 
311
+ // ------------------------------------------------------------------------
703
312
  } // namespace utility
704
313
 
705
314
  // --------------------------------------------------------------------------
@@ -713,12 +322,21 @@ namespace micro_os_plus::micro_test_plus
713
322
 
714
323
  #endif // __cplusplus
715
324
 
716
- // ===== Inline & template implementations ====================================
325
+ // ===== Inlines & templates implementations
326
+ // ====================================
327
+
328
+ // All inlines are included **after** all declarations.
329
+ #include "micro-test-plus/inlines/details-inlines.h"
330
+ #include "micro-test-plus/inlines/literals-inlines.h"
331
+ #include "micro-test-plus/inlines/math-inlines.h"
332
+
333
+ #include "micro-test-plus/inlines/reflection-inlines.h"
334
+ #include "micro-test-plus/inlines/test-reporter-inlines.h"
717
335
 
718
- #include "test-reporter-inlines.h"
336
+ #include "micro-test-plus/inlines/function-comparators-inlines.h"
337
+ #include "micro-test-plus/inlines/test-suite-inlines.h"
719
338
 
720
- // All other inlines.
721
- #include "inlines.h"
339
+ #include "micro-test-plus/inlines/micro-test-plus-inlines.h"
722
340
 
723
341
  // ----------------------------------------------------------------------------
724
342