@micro-os-plus/micro-test-plus 3.2.2 → 3.3.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 (45) hide show
  1. package/.cmake-format.yaml +11 -0
  2. package/CHANGELOG.md +417 -2
  3. package/CMakeLists.txt +33 -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 +1908 -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 +476 -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-basic.h +289 -0
  22. package/include/micro-os-plus/micro-test-plus/test-reporter-tap.h +281 -0
  23. package/include/micro-os-plus/micro-test-plus/test-reporter.h +846 -0
  24. package/include/micro-os-plus/micro-test-plus/test-runner.h +281 -0
  25. package/include/micro-os-plus/micro-test-plus/test-suite.h +492 -0
  26. package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
  27. package/include/micro-os-plus/micro-test-plus.h +172 -552
  28. package/meson.build +7 -5
  29. package/package.json +29 -34
  30. package/src/micro-test-plus.cpp +134 -37
  31. package/src/test-reporter-basic.cpp +466 -0
  32. package/src/test-reporter-tap.cpp +530 -0
  33. package/src/test-reporter.cpp +207 -240
  34. package/src/test-runner.cpp +135 -23
  35. package/src/test-suite.cpp +182 -10
  36. package/include/micro-os-plus/detail.h +0 -765
  37. package/include/micro-os-plus/inlines.h +0 -209
  38. package/include/micro-os-plus/literals.h +0 -512
  39. package/include/micro-os-plus/math.h +0 -204
  40. package/include/micro-os-plus/reflection.h +0 -139
  41. package/include/micro-os-plus/test-reporter-inlines.h +0 -230
  42. package/include/micro-os-plus/test-reporter.h +0 -356
  43. package/include/micro-os-plus/test-runner.h +0 -132
  44. package/include/micro-os-plus/test-suite.h +0 -306
  45. 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,21 @@
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"
79
+ #include "micro-test-plus/test-reporter-basic.h"
80
+ #include "micro-test-plus/test-reporter-tap.h"
37
81
 
38
82
  // ----------------------------------------------------------------------------
39
83
 
@@ -48,12 +92,36 @@
48
92
  #endif
49
93
  #endif
50
94
 
95
+ /**
96
+ * @namespace micro_os_plus::micro_test_plus
97
+ * @brief Primary namespace for the µTest++ testing framework.
98
+ *
99
+ * @details
100
+ * The `micro_os_plus::micro_test_plus` namespace encapsulates all core
101
+ * components, types, and utilities of the µTest++ testing framework, providing
102
+ * a dedicated scope for its public API.
103
+ *
104
+ * This namespace is structured into several nested namespaces, each
105
+ * responsible for a specific aspect of the framework, such as mathematical
106
+ * utilities, type traits, literals, test suite and test case management, test
107
+ * runners, test reporters, internal details, operators, and utility functions.
108
+ *
109
+ * By grouping all definitions within this namespace and its sub-namespaces,
110
+ * the framework achieves clear code organisation, minimises naming conflicts,
111
+ * and enhances maintainability. This modular structure supports robust,
112
+ * scalable, and professional test development for both embedded and general
113
+ * C++ projects.
114
+ *
115
+ * All public API definitions are implemented in the `include/micro-os-plus`
116
+ * folder, ensuring a clear separation from user code and facilitating
117
+ * straightforward integration with the wider µOS++ ecosystem.
118
+ */
51
119
  namespace micro_os_plus::micro_test_plus
52
120
  {
53
121
  // --------------------------------------------------------------------------
54
122
 
55
123
  extern test_runner runner;
56
- extern test_reporter reporter;
124
+ extern test_reporter* reporter;
57
125
  extern test_suite_base* current_test_suite;
58
126
 
59
127
  // --------------------------------------------------------------------------
@@ -61,10 +129,12 @@ namespace micro_os_plus::micro_test_plus
61
129
 
62
130
  /**
63
131
  * @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.
132
+ * @brief Initialise the µTest++ framework.
133
+ *
134
+ * @param [in] argc The number of command-line arguments.
135
+ * @param [in] argv Array of pointers to null-terminated argument strings.
136
+ * @param [in] name The name of the default test suite. Defaults to `"Main"`
137
+ * if not specified.
68
138
  * @par Returns
69
139
  * Nothing.
70
140
  */
@@ -73,10 +143,11 @@ namespace micro_os_plus::micro_test_plus
73
143
 
74
144
  /**
75
145
  * @ingroup micro-test-plus-inits
76
- * @brief Complete the test and return the exit code.
146
+ * @brief Complete the test run and return the exit code.
147
+ *
77
148
  * @par Parameters
78
- * None.
79
- * @return 0 for success, 1 for failure.
149
+ * None.
150
+ * @return 0 if all tests were successful, 1 if any test failed.
80
151
  */
81
152
  [[nodiscard]] int
82
153
  exit_code (void);
@@ -84,14 +155,15 @@ namespace micro_os_plus::micro_test_plus
84
155
  /**
85
156
  * @ingroup micro-test-plus-test-case
86
157
  * @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.
158
+ *
159
+ * @tparam Callable_T The type of the callable object to be executed as the
160
+ * test case.
161
+ * @tparam Args_T The types of the arguments to be passed to the callable.
162
+ * @param [in] name The test case name or description, used in test reports.
163
+ * @param [in] callable A generic callable object, usually a lambda, invoked
164
+ * to perform the test.
165
+ * @param [in] arguments A possibly empty list of arguments to be passed to
166
+ * the callable.
95
167
  * @par Returns
96
168
  * Nothing.
97
169
  */
@@ -102,34 +174,17 @@ namespace micro_os_plus::micro_test_plus
102
174
  /**
103
175
  * @ingroup micro-test-plus-expectations
104
176
  * @brief Evaluate a generic condition and report the results.
105
- * @tparam Expr_T The type of the custom expression.
106
- * @param [in] expr Logical expression to evaluate.
107
- * @param [in] sl Optional source location, by default the current line.
108
- * @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
177
  *
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)`.
178
+ * @tparam Expr_T The type of the custom expression.
126
179
  *
127
- * @par Example
128
- * ```cpp
129
- * namespace mt = micro_os_plus::micro_test_plus;
180
+ * @par SFINAE
181
+ * Enabled only if `Expr_T` is derived from `detail::op` or
182
+ * is convertible to `bool`.
130
183
  *
131
- * mt::expect (compute_answer () == 42) << "answer is 42";
132
- * ```
184
+
185
+ * @param [in] expr Logical expression to evaluate.
186
+ * @param [in] sl Optional source location, defaulting to the current line.
187
+ * @return An output stream to write optional messages.
133
188
  */
134
189
  template <class Expr_T, type_traits::requires_t<
135
190
  type_traits::is_op_v<Expr_T>
@@ -137,29 +192,21 @@ namespace micro_os_plus::micro_test_plus
137
192
  = 0>
138
193
  constexpr auto
139
194
  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
- }
195
+ = reflection::source_location::current ());
144
196
 
145
197
  /**
146
198
  * @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.
199
+ * @brief Check a condition and, if false, abort test execution.
152
200
  *
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.
201
+ * @tparam Expr_T The type of the custom expression.
156
202
  *
157
- * @par Example
158
- * ```cpp
159
- * namespace mt = micro_os_plus::micro_test_plus;
203
+ * @par SFINAE
204
+ * Enabled only if `Expr_T` is derived from `detail::op` or
205
+ * is convertible to `bool`.
160
206
  *
161
- * mt::assume (compute_answer () == 42) << "answer is 42";
162
- * ```
207
+ * @param [in] expr Logical expression to evaluate.
208
+ * @param [in] sl Optional source location, defaulting to the current line.
209
+ * @return An output stream to write optional messages.
163
210
  */
164
211
  template <class Expr_T, type_traits::requires_t<
165
212
  type_traits::is_op_v<Expr_T>
@@ -167,522 +214,83 @@ namespace micro_os_plus::micro_test_plus
167
214
  = 0>
168
215
  constexpr auto
169
216
  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
- }
217
+ = reflection::source_location::current ());
174
218
 
175
219
  // --------------------------------------------------------------------------
176
220
 
177
221
  #if defined(__cpp_exceptions)
222
+
178
223
  /**
179
224
  * @ingroup micro-test-plus-exceptions
180
225
  * @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.
226
+ *
227
+ * @tparam Exception_T The type of the exception expected to be thrown.
228
+ * @tparam Callable_T The type of the callable object to be invoked.
229
+ * @param [in] func The callable object to check for exception throwing
230
+ * behaviour.
184
231
  * @return An output stream to write optional messages.
185
232
  */
186
233
  template <class Exception_T, class Callable_T>
187
234
  [[nodiscard]] constexpr auto
188
- throws (const Callable_T& func)
189
- {
190
- return detail::throws_<Callable_T, Exception_T>{ func };
191
- }
235
+ throws (const Callable_T& func);
192
236
 
193
237
  /**
194
238
  * @ingroup micro-test-plus-exceptions
195
239
  * @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.
240
+ *
241
+ * @tparam Callable_T The type of the callable object to be invoked.
242
+ * @param [in] func The callable object to check for exception throwing
243
+ * behaviour.
198
244
  * @return An output stream to write optional messages.
199
245
  */
200
246
  template <class Callable_T>
201
247
  [[nodiscard]] constexpr auto
202
- throws (const Callable_T& func)
203
- {
204
- return detail::throws_<Callable_T>{ func };
205
- }
248
+ throws (const Callable_T& func);
206
249
 
207
250
  /**
208
251
  * @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.
252
+ * @brief Check if a callable does not throw an exception.
253
+ *
254
+ * @tparam Callable_T The type of the callable object to be invoked.
255
+ * @param [in] func The callable object to check for exception safety.
212
256
  * @return An output stream to write optional messages.
213
257
  */
214
258
  template <class Callable_T>
215
259
  [[nodiscard]] constexpr auto
216
- nothrow (const Callable_T& func)
217
- {
218
- return detail::nothrow_{ func };
219
- }
260
+ nothrow (const Callable_T& func);
261
+
220
262
  #endif
221
263
 
222
264
  // --------------------------------------------------------------------------
223
265
 
224
266
  /**
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.
267
+ * @namespace micro_os_plus::micro_test_plus::utility
268
+ * @brief Utility functions for the µTest++ testing framework.
444
269
  *
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.
270
+ * @details
271
+ * The `micro_os_plus::micro_test_plus::utility` namespace provides a suite
272
+ * of helper functions designed to support advanced string operations and
273
+ * other common tasks within the µTest++ framework.
490
274
  *
491
- * @warning Please note that they
492
- * may interfere with other operators existing in the tested application.
275
+ * These utilities include functions for pattern matching—such as verifying
276
+ * whether a string matches a specified pattern—and for splitting strings
277
+ * into sub-strings based on delimiters. The implementations are efficient
278
+ * and suitable for both embedded and general C++ projects.
493
279
  *
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(...)`).
280
+ * By encapsulating these helper functions within a dedicated namespace, the
281
+ * framework maintains clear code organisation and minimises naming
282
+ * conflicts.
498
283
  */
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
284
  namespace utility
679
285
  {
680
286
  /**
681
287
  * @ingroup micro-test-plus-utility-functions
682
288
  * @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.
289
+ *
290
+ * @param [in] input The string view to be checked.
291
+ * @param [in] pattern The string view containing the pattern to match.
292
+ * @return `true` if the input string matches the pattern; otherwise,
293
+ * `false`.
686
294
  */
687
295
  [[nodiscard]] bool
688
296
  is_match (std::string_view input, std::string_view pattern);
@@ -690,16 +298,19 @@ namespace micro_os_plus::micro_test_plus
690
298
  /**
691
299
  * @ingroup micro-test-plus-utility-functions
692
300
  * @brief Split a string into a vector of sub-strings.
301
+ *
693
302
  * @tparam T Type of the input string.
694
303
  * @tparam Delim_T Type of the delimiter.
304
+ *
695
305
  * @param [in] input Input string to split.
696
306
  * @param [in] delim Delimiter string.
697
- * @return An array of strings.
307
+ * @return A vector containing the resulting sub-strings.
698
308
  */
699
309
  template <class T, class Delim_T>
700
310
  [[nodiscard]] auto
701
311
  split (T input, Delim_T delim) -> std::vector<T>;
702
312
 
313
+ // ------------------------------------------------------------------------
703
314
  } // namespace utility
704
315
 
705
316
  // --------------------------------------------------------------------------
@@ -713,12 +324,21 @@ namespace micro_os_plus::micro_test_plus
713
324
 
714
325
  #endif // __cplusplus
715
326
 
716
- // ===== Inline & template implementations ====================================
327
+ // ===== Inlines & templates implementations
328
+ // ====================================
329
+
330
+ // All inlines are included **after** all declarations.
331
+ #include "micro-test-plus/inlines/details-inlines.h"
332
+ #include "micro-test-plus/inlines/literals-inlines.h"
333
+ #include "micro-test-plus/inlines/math-inlines.h"
334
+
335
+ #include "micro-test-plus/inlines/reflection-inlines.h"
336
+ #include "micro-test-plus/inlines/test-reporter-inlines.h"
717
337
 
718
- #include "test-reporter-inlines.h"
338
+ #include "micro-test-plus/inlines/function-comparators-inlines.h"
339
+ #include "micro-test-plus/inlines/test-suite-inlines.h"
719
340
 
720
- // All other inlines.
721
- #include "inlines.h"
341
+ #include "micro-test-plus/inlines/micro-test-plus-inlines.h"
722
342
 
723
343
  // ----------------------------------------------------------------------------
724
344