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