@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
@@ -0,0 +1,341 @@
1
+ /*
2
+ * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
+ *
11
+ * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
+ * released under the terms of the Boost Version 1.0 Software License,
13
+ * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
+ */
15
+
16
+ // ----------------------------------------------------------------------------
17
+
18
+ /**
19
+ * @file
20
+ * @brief C++ header file with inline implementations for the µTest++ function
21
+ * comparators.
22
+ *
23
+ * @details
24
+ * This header provides the inline implementations for the function comparator
25
+ * templates used within the µTest++ framework. It defines the logic for
26
+ * generic and pointer-based comparison operators, including equality,
27
+ * non-equality, greater than, less than, and their respective logical
28
+ * variants. Additionally, it implements logical combinators such as
29
+ * conjunction (_and), disjunction (_or), and negation (_not), as well as a
30
+ * utility for safely removing constness from objects.
31
+ *
32
+ * These comparators and logical operators enable expressive and type-safe test
33
+ * expectations and assertions, supporting both value and pointer semantics.
34
+ * The underscore-prefixed logical operators are intentionally named to avoid
35
+ * conflicts with standard operators.
36
+ *
37
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
38
+ * namespace, ensuring clear separation from user code and minimising the risk
39
+ * of naming conflicts.
40
+ *
41
+ * The header files are organised within the
42
+ * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
43
+ * modular codebase.
44
+ *
45
+ * This file is intended solely for internal use within the framework and
46
+ * should not be included directly by user code.
47
+ */
48
+
49
+ #ifndef MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
50
+ #define MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
51
+
52
+ // ----------------------------------------------------------------------------
53
+
54
+ #ifdef __cplusplus
55
+
56
+ // ----------------------------------------------------------------------------
57
+
58
+ // #include "detail.h"
59
+
60
+ // ----------------------------------------------------------------------------
61
+
62
+ #if defined(__GNUC__)
63
+ #pragma GCC diagnostic push
64
+ #pragma GCC diagnostic ignored "-Waggregate-return"
65
+ #if defined(__clang__)
66
+ #pragma clang diagnostic ignored "-Wc++98-compat"
67
+ #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
68
+ #endif
69
+ #endif
70
+
71
+ namespace micro_os_plus::micro_test_plus
72
+ {
73
+ // --------------------------------------------------------------------------
74
+
75
+ /**
76
+ * @details
77
+ * The `eq` function template provides a generic equality comparator for any
78
+ * non-pointer types. It constructs a comparator object that can be used
79
+ * within the µTest++ framework to assert that two values are equal. This
80
+ * function is typically used in test expectations and assertions to compare
81
+ * the actual and expected values.
82
+ */
83
+ template <class Lhs_T, class Rhs_T>
84
+ [[nodiscard]] constexpr auto
85
+ eq (const Lhs_T& lhs, const Rhs_T& rhs)
86
+ {
87
+ return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
88
+ }
89
+
90
+ /**
91
+ * @details
92
+ * The `eq` function template provides a pointer equality comparator for any
93
+ * pointer types. It constructs a comparator object that can be used within
94
+ * the µTest++ framework to assert that two pointers are equal. This function
95
+ * is typically used in test expectations and assertions to compare the
96
+ * addresses of objects or resources.
97
+ */
98
+ template <class Lhs_T, class Rhs_T>
99
+ [[nodiscard]] constexpr auto
100
+ eq (Lhs_T* lhs, Rhs_T* rhs)
101
+ {
102
+ return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
103
+ }
104
+
105
+ /**
106
+ * @details
107
+ * The `ne` function template provides a generic non-equality comparator for
108
+ * any types. It constructs a comparator object that can be used within the
109
+ * µTest++ framework to assert that two values are not equal. This function
110
+ * is typically used in test expectations and assertions to compare the
111
+ * actual and expected values.
112
+ */
113
+ template <class Lhs_T, class Rhs_T>
114
+ [[nodiscard]] constexpr auto
115
+ ne (const Lhs_T& lhs, const Rhs_T& rhs)
116
+ {
117
+ return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
118
+ }
119
+
120
+ /**
121
+ * @details
122
+ * The `ne` function template provides a pointer non-equality comparator for
123
+ * any pointer types. It constructs a comparator object that can be used
124
+ * within the µTest++ framework to assert that two pointers are not equal.
125
+ * This function is typically used in test expectations and assertions to
126
+ * compare the addresses of objects or resources.
127
+ */
128
+ template <class Lhs_T, class Rhs_T>
129
+ [[nodiscard]] constexpr auto
130
+ ne (Lhs_T* lhs, Rhs_T* rhs)
131
+ {
132
+ return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
133
+ }
134
+
135
+ /**
136
+ * @details
137
+ * The `gt` function template provides a generic greater than comparator for
138
+ * any types. It constructs a comparator object that can be used within the
139
+ * µTest++ framework to assert that one value is greater than another. This
140
+ * function is typically used in test expectations and assertions to compare
141
+ * the actual and expected values.
142
+ */
143
+ template <class Lhs_T, class Rhs_T>
144
+ [[nodiscard]] constexpr auto
145
+ gt (const Lhs_T& lhs, const Rhs_T& rhs)
146
+ {
147
+ return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
148
+ }
149
+
150
+ /**
151
+ * @details
152
+ * The `gt` function template provides a pointer greater than comparator for
153
+ * any pointer types. It constructs a comparator object that can be used
154
+ * within the µTest++ framework to assert that one pointer is greater than
155
+ * another. This function is typically used in test expectations and
156
+ * assertions to compare the addresses of objects or resources.
157
+ */
158
+ template <class Lhs_T, class Rhs_T>
159
+ [[nodiscard]] constexpr auto
160
+ gt (Lhs_T* lhs, Rhs_T* rhs)
161
+ {
162
+ return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
163
+ }
164
+
165
+ /**
166
+ * @details
167
+ * The `ge` function template provides a generic greater than or equal
168
+ * comparator for any types. It constructs a comparator object that can be
169
+ * used within the µTest++ framework to assert that one value is greater than
170
+ * or equal to another. This function is typically used in test expectations
171
+ * and assertions to compare the actual and expected values.
172
+ */
173
+ template <class Lhs_T, class Rhs_T>
174
+ [[nodiscard]] constexpr auto
175
+ ge (const Lhs_T& lhs, const Rhs_T& rhs)
176
+ {
177
+ return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
178
+ }
179
+
180
+ /**
181
+ * @details
182
+ * The `ge` function template provides a pointer greater than or equal
183
+ * comparator for any pointer types. It constructs a comparator object that
184
+ * can be used within the µTest++ framework to assert that one pointer is
185
+ * greater than or equal to another. This function is typically used in test
186
+ * expectations and assertions to compare the addresses of objects or
187
+ * resources.
188
+ */
189
+ template <class Lhs_T, class Rhs_T>
190
+ [[nodiscard]] constexpr auto
191
+ ge (Lhs_T* lhs, Rhs_T* rhs)
192
+ {
193
+ return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
194
+ }
195
+
196
+ /**
197
+ * @details
198
+ * The `lt` function template provides a generic less than comparator for any
199
+ * types. It constructs a comparator object that can be used within the
200
+ * µTest++ framework to assert that one value is less than another. This
201
+ * function is typically used in test expectations and assertions to compare
202
+ * the actual and expected values.
203
+ */
204
+ template <class Lhs_T, class Rhs_T>
205
+ [[nodiscard]] constexpr auto
206
+ lt (const Lhs_T& lhs, const Rhs_T& rhs)
207
+ {
208
+ return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
209
+ }
210
+
211
+ /**
212
+ * @details
213
+ * The `lt` function template provides a pointer less than comparator for any
214
+ * pointer types. It constructs a comparator object that can be used within
215
+ * the µTest++ framework to assert that one pointer is less than another.
216
+ * This function is typically used in test expectations and assertions to
217
+ * compare the addresses of objects or resources.
218
+ */
219
+ template <class Lhs_T, class Rhs_T>
220
+ [[nodiscard]] constexpr auto
221
+ lt (Lhs_T* lhs, Rhs_T* rhs)
222
+ {
223
+ return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
224
+ }
225
+
226
+ /**
227
+ * @details
228
+ * The `le` function template provides a generic less than or equal
229
+ * comparator for any types. It constructs a comparator object that can be
230
+ * used within the µTest++ framework to assert that one value is less than or
231
+ * equal to another. This function is typically used in test expectations and
232
+ * assertions to compare the actual and expected values.
233
+ */
234
+ template <class Lhs_T, class Rhs_T>
235
+ [[nodiscard]] constexpr auto
236
+ le (const Lhs_T& lhs, const Rhs_T& rhs)
237
+ {
238
+ return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
239
+ }
240
+
241
+ /**
242
+ * @details
243
+ * The `le` function template provides a pointer less than or equal
244
+ * comparator for any pointer types. It constructs a comparator object that
245
+ * can be used within the µTest++ framework to assert that one pointer is
246
+ * less than or equal to another. This function is typically used in test
247
+ * expectations and assertions to compare the addresses of objects or
248
+ * resources.
249
+ */
250
+ template <class Lhs_T, class Rhs_T>
251
+ [[nodiscard]] constexpr auto
252
+ le (Lhs_T* lhs, Rhs_T* rhs)
253
+ {
254
+ return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
255
+ }
256
+
257
+ /**
258
+ * @details
259
+ * The `_not` function template provides a generic logical negation for any
260
+ * expression type. It constructs a logical negator object that can be used
261
+ * within the µTest++ framework to assert that a given condition is false.
262
+ * This function is typically used in test expectations and assertions to
263
+ * invert logical expressions or custom comparators.
264
+ *
265
+ * The underscore in the function name is intentional to differentiate it
266
+ * from the standard logical not operator.
267
+ */
268
+ template <class Expr_T>
269
+ [[nodiscard]] constexpr auto
270
+ _not (const Expr_T& expr)
271
+ {
272
+ return detail::not_<Expr_T>{ expr };
273
+ }
274
+
275
+ /**
276
+ * @details
277
+ * The `_and` function template provides a generic logical conjunction for
278
+ * any expression types. It constructs a logical conjunction object that can
279
+ * be used within the µTest++ framework to assert that both given conditions
280
+ * are true. This function is typically used in test expectations and
281
+ * assertions to combine logical expressions or custom comparators.
282
+ *
283
+ * The underscore in the function name is intentional to differentiate it
284
+ * from the standard logical and operator.
285
+ */
286
+ template <class Lhs_T, class Rhs_T>
287
+ [[nodiscard]] constexpr auto
288
+ _and (const Lhs_T& lhs, const Rhs_T& rhs)
289
+ {
290
+ return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
291
+ }
292
+
293
+ /**
294
+ * @details
295
+ * The `_or` function template provides a generic logical disjunction for any
296
+ * expression types. It constructs a logical disjunction object that can be
297
+ * used within the µTest++ framework to assert that at least one of the given
298
+ * conditions is true. This function is typically used in test expectations
299
+ * and assertions to combine logical expressions or custom comparators.
300
+ *
301
+ * The underscore in the function name is intentional to differentiate it
302
+ * from the standard logical or operator.
303
+ */
304
+ template <class Lhs_T, class Rhs_T>
305
+ [[nodiscard]] constexpr auto
306
+ _or (const Lhs_T& lhs, const Rhs_T& rhs)
307
+ {
308
+ return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
309
+ }
310
+
311
+ /**
312
+ * @details
313
+ * The `mut` function template provides a safe and generic mechanism to
314
+ * remove the `const` qualifier from any type. It returns a non-const
315
+ * reference to the input object, enabling modification of objects that were
316
+ * originally declared as `const`. This utility is particularly useful in
317
+ * testing scenarios where controlled mutation of test data is required.
318
+ */
319
+ template <class T>
320
+ [[nodiscard]] constexpr auto
321
+ mut (const T& t) noexcept -> T&
322
+ {
323
+ return const_cast<T&> (t);
324
+ }
325
+
326
+ // --------------------------------------------------------------------------
327
+ } // namespace micro_os_plus::micro_test_plus
328
+
329
+ #if defined(__GNUC__)
330
+ #pragma GCC diagnostic pop
331
+ #endif
332
+
333
+ // ----------------------------------------------------------------------------
334
+
335
+ #endif // __cplusplus
336
+
337
+ // ----------------------------------------------------------------------------
338
+
339
+ #endif // MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
340
+
341
+ // ----------------------------------------------------------------------------