@micro-os-plus/micro-test-plus 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/CMakeLists.txt +74 -24
  3. package/README.md +3 -2
  4. package/include/micro-os-plus/micro-test-plus/README.md +6 -0
  5. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +29 -54
  6. package/include/micro-os-plus/micro-test-plus/detail.h +166 -705
  7. package/include/micro-os-plus/micro-test-plus/exceptions.h +5 -6
  8. package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
  9. package/include/micro-os-plus/micro-test-plus/function-comparators.h +5 -0
  10. package/include/micro-os-plus/micro-test-plus/inlines/deferred-reporter-inlines.h +25 -30
  11. package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
  12. package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/expression-formatter-inlines.h +510 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +17 -76
  15. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +47 -25
  16. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +7 -7
  17. package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
  18. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +4 -4
  19. package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +53 -394
  20. package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +38 -0
  21. package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
  22. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +231 -45
  23. package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
  24. package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +231 -0
  25. package/include/micro-os-plus/micro-test-plus/literals.h +8 -14
  26. package/include/micro-os-plus/micro-test-plus/math.h +5 -0
  27. package/include/micro-os-plus/micro-test-plus/operators.h +19 -169
  28. package/include/micro-os-plus/micro-test-plus/reflection.h +5 -12
  29. package/include/micro-os-plus/micro-test-plus/reporter-human.h +17 -11
  30. package/include/micro-os-plus/micro-test-plus/reporter-tap.h +14 -8
  31. package/include/micro-os-plus/micro-test-plus/reporter.h +101 -424
  32. package/include/micro-os-plus/micro-test-plus/runner-totals.h +162 -176
  33. package/include/micro-os-plus/micro-test-plus/runner.h +61 -42
  34. package/include/micro-os-plus/micro-test-plus/test.h +450 -506
  35. package/include/micro-os-plus/micro-test-plus/timings.h +259 -262
  36. package/include/micro-os-plus/micro-test-plus/type-traits.h +19 -67
  37. package/include/micro-os-plus/micro-test-plus/utility.h +5 -4
  38. package/include/micro-os-plus/micro-test-plus.h +33 -24
  39. package/meson.build +1 -0
  40. package/package.json +11 -3
  41. package/src/deferred-reporter.cpp +21 -2
  42. package/src/expression-formatter.cpp +289 -0
  43. package/src/reflection.cpp +3 -1
  44. package/src/reporter-human.cpp +31 -37
  45. package/src/reporter-tap.cpp +25 -35
  46. package/src/reporter.cpp +36 -231
  47. package/src/runner-totals.cpp +6 -3
  48. package/src/runner.cpp +131 -25
  49. package/src/test.cpp +120 -113
  50. package/src/timings.cpp +6 -5
  51. package/src/utility.cpp +1 -1
package/CHANGELOG.md CHANGED
@@ -6,8 +6,90 @@ Please check
6
6
  [GitHub](https://github.com/micro-os-plus/micro-test-plus-xpack/issues/)
7
7
  and close existing issues and pull requests.
8
8
 
9
+ ## 2026-05-11
10
+
11
+ * v4.1.0 published on npmjs.com
12
+ * 353d2a1 CmakeLists.txt add CXX
13
+ * 68c840b CMake cosmetics in comments
14
+ * 6ba1ac4 CMakeLists.txt duplicate fix
15
+ * 4ea4a84 website doxygen update
16
+ * 5810287 prepare v4.1.0
17
+ * 496bf98 re-generate website commons
18
+ * 4f3a2b9 use local cmake-format & reformat
19
+
20
+ ## 2026-05-10
21
+
22
+ * fe8d5ac use local clang-format & reformat
23
+ * 9239eca #31: move the top default suite name to initialise()
24
+ * 478a667 website/package*.json update
25
+ * d69a6be re-generate website commons
26
+ * 7e0d3f9 config.doxyfile: add EXCLUDE_PATTERNS
27
+ * 86596a2 update .dox files to remove repetitions
28
+ * dded41a copilot-instructions.md update
29
+ * fbe0cd9 detail.h: add @details
30
+
31
+ ## 2026-05-09
32
+
33
+ * 597515f website update
34
+ * 88dd73c detail::indent_t
35
+ * a835441 doxygen update
36
+ * a903306 cleanups for includes
37
+ * 8a6ab9f cmake: disable coverage
38
+ * d4216c5 #28: fix circular dependency
39
+ * 8004f37 #28: more includes reworks
40
+
41
+ ## 2026-05-08
42
+
43
+ * 5b55e3f #28: more inlines fixed, only test-inlines.h remaining
44
+ * 9dd8012 fix illegal character
45
+ * 26675c5 #30: Move internal classes to details namespace
46
+ * cbf8e4c extract exceptions-inline.h
47
+ * fbca56c remove nodiscard from definitions
48
+ * 4ed019a #29: Extract expression formatting code from reporter
49
+ * 9b1369d Merge branch 'xpack-development' of https://github.com/micro-os-plus/micro-test-plus-xpack into xpack-development
50
+ * 4ef8a04 #29: Extract expression formatting code from reporter
51
+ * c9bf9b1 #29: Extract expression formatting code from reporter
52
+
53
+ ## 2026-05-07
54
+
55
+ * d25e887 #28: Re-organise inlines
56
+
57
+ ## 2026-05-06
58
+
59
+ * 5c2c832 tests: use add_compile_common_private_options
60
+ * 404fdd2 test-inlines.h: silence warning
61
+ * ee30572 re-generate commons
62
+ * ab9c415 re-generate top commons
63
+ * e8f23ee #27: Split definitions from declarations
64
+ * f6aaa8a tests: use add_compile_common_private_options
65
+
66
+ ## 2026-05-04
67
+
68
+ * 536e327 website update
69
+
70
+ ## 2026-04-30
71
+
72
+ * aca5767 platforms/native: remove -stdlib=libc++ from non clang
73
+ * 0cef14e more guards & guard cosmetics
74
+ * e15b6d7 guard include diag/trace.h
75
+ * 0ad8f72 tests: include platform.h
76
+ * 8775c7f website user update
77
+ * 953cc21 includes: add guard to prevent direct includes
78
+
9
79
  ## 2026-04-29
10
80
 
81
+ * 8f330f5 re-generate tests commons
82
+ * 7c3b63d fix again blog autoformat
83
+ * e2ddd82 website updates
84
+ * f9a1b1a website: update last blog posts
85
+ * 730a42c website: add link to TAP
86
+ * 08aeb97 website: fix blog posts code block
87
+ * 88273bf .vscode/settings.json: do not reformat mdx
88
+ * 88107e3 re-generate website commons
89
+ * 14309a9 website: blog post release 4.0.0 published
90
+ * 07f01d3 blog posts cosmetics
91
+ * 6e72885 4.0.0
92
+ * cfd4b34 CHANGELOG: publish npm v4.0.0
11
93
  * v4.0.0 published on npmjs.com
12
94
  * 1105af3 re-format
13
95
  * ac64933 CHANGELOG update for v4.0.0
package/CMakeLists.txt CHANGED
@@ -24,7 +24,11 @@
24
24
  # https://cmake.org/cmake/help/v3.20/
25
25
  cmake_minimum_required (VERSION 3.20)
26
26
 
27
- project (micro-os-plus-micro-test-plus DESCRIPTION "µTest++")
27
+ project (
28
+ micro-os-plus-micro-test-plus
29
+ DESCRIPTION "µTest++"
30
+ LANGUAGES CXX
31
+ )
28
32
 
29
33
  # To access the optional functions, include the
30
34
  # `cmake/micro-os-plus-build-helper.cmake` file from the
@@ -41,11 +45,14 @@ endif ()
41
45
 
42
46
  # -----------------------------------------------------------------------------
43
47
 
44
- # The project library definitions.
48
+ # The interface library is the main target of this package, which consumers
49
+ # (like embedded applications) link against. It defines the public API and
50
+ # properties of the library, and compiles the sources that are part of the
51
+ # public API.
45
52
 
46
53
  # https://cmake.org/cmake/help/v3.20/command/add_library.html?highlight=interface#normal-libraries
47
- # PRIVATE: build definitions, used internally INTERFACE: usage definitions,
48
- # passed up to targets linking to it PUBLIC: both
54
+ # Visibility keywords: PRIVATE applies to the target itself; INTERFACE passes
55
+ # properties up to targets that link against it; PUBLIC does both.
49
56
  add_library (micro-os-plus-micro-test-plus-interface INTERFACE)
50
57
 
51
58
  target_include_directories (
@@ -57,6 +64,7 @@ target_sources (
57
64
  INTERFACE "src/runner.cpp"
58
65
  "src/runner-totals.cpp"
59
66
  "src/deferred-reporter.cpp"
67
+ "src/expression-formatter.cpp"
60
68
  "src/reporter.cpp"
61
69
  "src/reporter-human.cpp"
62
70
  "src/reporter-tap.cpp"
@@ -66,13 +74,9 @@ target_sources (
66
74
  "src/utility.cpp"
67
75
  )
68
76
 
69
- target_compile_definitions (
70
- micro-os-plus-micro-test-plus-interface INTERFACE # None.
71
- )
77
+ target_compile_definitions (micro-os-plus-micro-test-plus-interface INTERFACE)
72
78
 
73
- target_compile_options (
74
- micro-os-plus-micro-test-plus-interface INTERFACE # None.
75
- )
79
+ target_compile_options (micro-os-plus-micro-test-plus-interface INTERFACE)
76
80
 
77
81
  target_link_libraries (
78
82
  micro-os-plus-micro-test-plus-interface INTERFACE micro-os-plus::diag-trace
@@ -84,37 +88,83 @@ endif ()
84
88
 
85
89
  # -----------------------------------------------------------------------------
86
90
 
87
- # Optional OBJECT library: sources are compiled once rather than per consumer.
88
- # Inherits include directories, compile definitions, and compiler options from
89
- # the interface library via PRIVATE linkage, which avoids propagating the
90
- # interface library's INTERFACE sources to consumers of the object library. The
91
- # include directories are re-exported explicitly so that consumers can find the
92
- # headers.
91
+ # Optional OBJECT library: compiles the library sources once and shares the
92
+ # resulting object files across all test executables, rather than recompiling
93
+ # them per consumer.
94
+ #
95
+ # Include directories are managed explicitly instead of using PRIVATE linkage to
96
+ # the interface library. PRIVATE linkage would cause diag-trace's
97
+ # INTERFACE_SOURCES (trace.cpp) to be compiled into this OBJECT library via
98
+ # transitive propagation, which conflicts with the separate diag-trace
99
+ # compilation in each test executable. Consumers of this OBJECT library are
100
+ # expected to link separately to micro-os-plus::diag-trace and to the
101
+ # platform-specific trace backend.
93
102
  add_library (micro-os-plus-micro-test-plus-objects OBJECT)
94
103
 
95
- get_target_property (
104
+ get_property (
96
105
  micro-os-plus-micro-test-plus-includes
97
- micro-os-plus-micro-test-plus-interface INTERFACE_INCLUDE_DIRECTORIES
106
+ TARGET micro-os-plus-micro-test-plus-interface
107
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES
98
108
  )
109
+ # Use PUBLIC so that the include directories are available both for the OBJECT
110
+ # library's own sources and for consumers of the library.
99
111
  target_include_directories (
100
112
  micro-os-plus-micro-test-plus-objects
101
- INTERFACE ${micro-os-plus-micro-test-plus-includes}
113
+ PUBLIC ${micro-os-plus-micro-test-plus-includes}
102
114
  )
103
115
 
104
- get_target_property (
105
- micro-os-plus-micro-test-plus-sources micro-os-plus-micro-test-plus-interface
106
- INTERFACE_SOURCES
116
+ get_property (
117
+ micro-os-plus-micro-test-plus-sources
118
+ TARGET micro-os-plus-micro-test-plus-interface
119
+ PROPERTY INTERFACE_SOURCES
107
120
  )
121
+ # Use PRIVATE to avoid propagating the sources to consumers of the OBJECT
122
+ # library, which would cause duplicate symbol errors at link time.
108
123
  target_sources (
109
124
  micro-os-plus-micro-test-plus-objects
110
125
  PRIVATE ${micro-os-plus-micro-test-plus-sources}
111
126
  )
112
127
 
113
- target_link_libraries (
128
+ get_property (
129
+ micro-os-plus-micro-test-plus-compile-definitions
130
+ TARGET micro-os-plus-micro-test-plus-interface
131
+ PROPERTY INTERFACE_COMPILE_DEFINITIONS
132
+ )
133
+ # Use PRIVATE to avoid propagating compile definitions to consumers of the
134
+ # OBJECT library.
135
+ target_compile_definitions (
114
136
  micro-os-plus-micro-test-plus-objects
115
- PRIVATE micro-os-plus-micro-test-plus-interface
137
+ PRIVATE ${micro-os-plus-micro-test-plus-compile-definitions}
116
138
  )
117
139
 
140
+ get_property (
141
+ micro-os-plus-micro-test-plus-compile-options
142
+ TARGET micro-os-plus-micro-test-plus-interface
143
+ PROPERTY INTERFACE_COMPILE_OPTIONS
144
+ )
145
+ # Use PRIVATE to avoid propagating the compile options to consumers of the
146
+ # OBJECT library, which may cause conflicts with consumer-specific compile
147
+ # options.
148
+ target_compile_options (
149
+ micro-os-plus-micro-test-plus-objects
150
+ PRIVATE ${micro-os-plus-micro-test-plus-compile-options}
151
+ )
152
+
153
+ # Add the diag-trace include path in Debug without linking the diag-trace
154
+ # target: linking it would add trace.cpp as an INTERFACE_SOURCE and compile it
155
+ # into the OBJECT library, causing duplicate symbols at link time.
156
+ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
157
+ get_property (
158
+ micro-os-plus-diag-trace-includes
159
+ TARGET micro-os-plus::diag-trace
160
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES
161
+ )
162
+ target_include_directories (
163
+ micro-os-plus-micro-test-plus-objects
164
+ PRIVATE ${micro-os-plus-diag-trace-includes}
165
+ )
166
+ endif ()
167
+
118
168
  if (COMMAND xpack_display_target_lists)
119
169
  xpack_display_target_lists (micro-os-plus-micro-test-plus-objects)
120
170
  endif ()
package/README.md CHANGED
@@ -15,7 +15,8 @@ For information on how to install and use this project, please refer to the
15
15
  ## Project source
16
16
 
17
17
  The source code of the current release is available on
18
- [GitHub tag v4.0.0 tree](https://github.com/micro-os-plus/micro-test-plus-xpack/tree/v4.0.0).
18
+ GitHub as [micro-os-plus/micro-test-plus-xpack](https://github.com/micro-os-plus/micro-test-plus-xpack),
19
+ the [v4.1.0](https://github.com/micro-os-plus/micro-test-plus-xpack/tree/v4.1.0) tree.
19
20
 
20
21
  ## License
21
22
 
@@ -25,4 +26,4 @@ with all rights reserved to
25
26
  [Liviu Ionescu](https://github.com/ilg-ul).
26
27
 
27
28
  The code from Boost UT is released under the terms of the
28
- [Boost Version 1.0 Software License](https://www.boost.org/LICENSE_1_0.txt).
29
+ [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
@@ -0,0 +1,6 @@
1
+ # Project Headers
2
+
3
+ The files in this folder are intended for internal use only. Do not include
4
+ them directly in your projects.
5
+
6
+ Instead, include the public header `<micro-os-plus/micro-test-plus.h>`.
@@ -52,6 +52,10 @@
52
52
  #include <cstdio>
53
53
  #include <string>
54
54
 
55
+ #include "type-traits.h"
56
+ #include "reflection.h"
57
+ #include "expression-formatter.h"
58
+
55
59
  // ----------------------------------------------------------------------------
56
60
 
57
61
  #if defined(__GNUC__)
@@ -71,33 +75,9 @@ namespace micro_os_plus::micro_test_plus
71
75
 
72
76
  // --------------------------------------------------------------------------
73
77
 
74
- /**
75
- * @namespace micro_os_plus::micro_test_plus::detail
76
- * @brief Internal implementation details for the µTest++ framework.
77
- *
78
- * @details
79
- * The `detail` namespace encapsulates the internal mechanisms, helper
80
- * structures, and implementation utilities employed by the µTest++ testing
81
- * framework. These components do not form part of the public API and may be
82
- * modified without prior notice.
83
- *
84
- * Within this namespace, one will find assertion handling, generic getter
85
- * utilities, comparator structures for logical and relational operations,
86
- * mechanisms for exception checking, and base classes for deferred reporting
87
- * of test results.
88
- *
89
- * All definitions within `detail` are intended exclusively for internal use,
90
- * ensuring a clear distinction between user-facing and internal components.
91
- * This approach enhances maintainability, mitigates the risk of naming
92
- * conflicts, and keeps the public API succinct.
93
- *
94
- * The relevant header files are organised within the `include/micro-os-plus`
95
- * folder to maintain a structured and modular codebase.
96
- */
97
78
  namespace detail
98
79
  {
99
-
100
- // ------------------------------------------------------------------------
80
+ // ========================================================================
101
81
 
102
82
  /**
103
83
  * @brief Base class for a deferred reporter that collects messages into a
@@ -145,13 +125,15 @@ namespace micro_os_plus::micro_test_plus
145
125
  * @brief Deleted copy assignment operator to prevent copying.
146
126
  */
147
127
  deferred_reporter_base&
148
- operator= (const deferred_reporter_base&) = delete;
128
+ operator= (const deferred_reporter_base&)
129
+ = delete;
149
130
 
150
131
  /**
151
132
  * @brief Deleted move assignment operator to prevent moving.
152
133
  */
153
134
  deferred_reporter_base&
154
- operator= (deferred_reporter_base&&) = delete;
135
+ operator= (deferred_reporter_base&&)
136
+ = delete;
155
137
 
156
138
  /**
157
139
  * @brief Destructor for the deferred reporter base.
@@ -174,20 +156,13 @@ namespace micro_os_plus::micro_test_plus
174
156
  /**
175
157
  * @brief Retrieves the result value.
176
158
  *
177
- *
178
159
  * @par Parameters
179
160
  * None.
180
161
  * @retval true The reported condition was met.
181
162
  * @retval false The reported condition was not met.
182
- *
183
- * @details
184
- * Returns the result value associated with the report.
185
163
  */
186
164
  [[nodiscard]] bool
187
- value () const
188
- {
189
- return value_;
190
- }
165
+ value () const;
191
166
 
192
167
  protected:
193
168
  /**
@@ -201,6 +176,11 @@ namespace micro_os_plus::micro_test_plus
201
176
  */
202
177
  bool abort_ = false;
203
178
 
179
+ /**
180
+ * @brief Indicates whether the reporter has an associated expression.
181
+ */
182
+ bool has_expression_ = false;
183
+
204
184
  /**
205
185
  * @brief Stores the source location associated with the report.
206
186
  */
@@ -218,19 +198,17 @@ namespace micro_os_plus::micro_test_plus
218
198
  subtest& subtest_;
219
199
  };
220
200
 
221
- // ------------------------------------------------------------------------
201
+ // ========================================================================
222
202
 
223
203
  /**
224
- * @brief Deferred reporter class template for a specific expression.
225
- *
226
- * @tparam Expr_T The type of the expression being reported.
204
+ * @brief Deferred reporter class for a specific expression.
227
205
  *
228
206
  * @details
229
- * The `deferred_reporter` class template extends `deferred_reporter_base`
207
+ * The `deferred_reporter` class extends `deferred_reporter_base`
230
208
  * to provide deferred reporting functionality for a specific test
231
209
  * expression within the framework.
232
210
  *
233
- * This class template is responsible for capturing the expression under
211
+ * This class is responsible for capturing the expression under
234
212
  * evaluation, the abort status, and the source location. It is intended
235
213
  * exclusively for internal use and is implemented in the
236
214
  * `include/micro-os-plus/micro-test-plus` folder to ensure a structured
@@ -238,7 +216,6 @@ namespace micro_os_plus::micro_test_plus
238
216
  *
239
217
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
240
218
  */
241
- template <class Expr_T>
242
219
  class deferred_reporter : public deferred_reporter_base
243
220
  {
244
221
  public:
@@ -250,25 +227,18 @@ namespace micro_os_plus::micro_test_plus
250
227
  * processing.
251
228
  * @param location The source location relevant to the report.
252
229
  * @param subtest The subtest that owns this deferred report.
253
- *
254
- * @details
255
- * Initialises the reporter with the given expression, abort status, and
256
- * source location.
230
+ * @param expression The expression formatter to format the expression
231
+ * text.
257
232
  */
233
+ template <class Expr_T>
258
234
  deferred_reporter (const Expr_T& expr, bool abort,
259
235
  const reflection::source_location& location,
260
- subtest& subtest);
236
+ subtest& subtest, expression_formatter& expression);
261
237
 
262
238
  /**
263
239
  * @brief Destructor for the deferred reporter.
264
240
  */
265
- ~deferred_reporter ();
266
-
267
- protected:
268
- /**
269
- * @brief Stores the expression under evaluation.
270
- */
271
- const Expr_T expr_{};
241
+ ~deferred_reporter () = default;
272
242
  };
273
243
 
274
244
  // ------------------------------------------------------------------------
@@ -285,6 +255,11 @@ namespace micro_os_plus::micro_test_plus
285
255
 
286
256
  #endif // __cplusplus
287
257
 
258
+ // ============================================================================
259
+ // Templates & constexpr implementations.
260
+
261
+ #include "inlines/deferred-reporter-inlines.h"
262
+
288
263
  // ----------------------------------------------------------------------------
289
264
 
290
265
  #endif // MICRO_TEST_PLUS_DEFERRED_REPORTER_H_