@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
@@ -0,0 +1,281 @@
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 declarations for the µTest++ TAP test reporter.
21
+ *
22
+ * @details
23
+ * This header provides the declaration for `test_reporter_tap`, a concrete
24
+ * implementation of the `test_reporter` abstract interface that formats test
25
+ * results according to the Test Anything Protocol (TAP).
26
+ *
27
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
28
+ * namespace, ensuring clear separation from user code and minimising the risk
29
+ * of naming conflicts.
30
+ *
31
+ * The header files are organised within the
32
+ * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
33
+ * modular codebase.
34
+ *
35
+ * This file is intended solely for internal use within the framework and
36
+ * should not be included directly by user code.
37
+ */
38
+
39
+ #ifndef MICRO_TEST_PLUS_TEST_REPORTER_TAP_H_
40
+ #define MICRO_TEST_PLUS_TEST_REPORTER_TAP_H_
41
+
42
+ // ----------------------------------------------------------------------------
43
+
44
+ #ifdef __cplusplus
45
+
46
+ // ----------------------------------------------------------------------------
47
+
48
+ #include "test-reporter.h"
49
+
50
+ // ----------------------------------------------------------------------------
51
+
52
+ #if defined(__GNUC__)
53
+ #pragma GCC diagnostic push
54
+ #pragma GCC diagnostic ignored "-Wpadded"
55
+ #if defined(__clang__)
56
+ #pragma clang diagnostic ignored "-Wc++98-compat"
57
+ #endif
58
+ #endif
59
+
60
+ namespace micro_os_plus::micro_test_plus
61
+ {
62
+ // --------------------------------------------------------------------------
63
+
64
+ /**
65
+ * @brief TAP (Test Anything Protocol) implementation of `test_reporter`.
66
+ *
67
+ * @details
68
+ * `test_reporter_tap` provides a concrete implementation of the
69
+ * `test_reporter` abstract interface that formats test results according to
70
+ * the Test Anything Protocol (TAP). It accumulates output in an internal
71
+ * string buffer and writes it to the standard output stream.
72
+ *
73
+ * Users who require custom output behaviour (e.g. redirecting to a serial
74
+ * port on bare-metal targets) may derive a new class from `test_reporter`
75
+ * and supply an instance via the `reporter` global pointer before calling
76
+ * `initialize()`.
77
+ *
78
+ * All members and methods are defined within the
79
+ * `micro_os_plus::micro_test_plus` namespace, ensuring clear separation from
80
+ * user code and minimising the risk of naming conflicts.
81
+ *
82
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
83
+ */
84
+ class test_reporter_tap final : public test_reporter
85
+ {
86
+ public:
87
+ /**
88
+ * @brief Default constructor for the test_reporter_tap class.
89
+ *
90
+ * @details
91
+ * The rule of five is enforced to prevent accidental copying or moving.
92
+ */
93
+ test_reporter_tap () = default;
94
+
95
+ /**
96
+ * @brief Deleted copy constructor to prevent copying.
97
+ */
98
+ test_reporter_tap (const test_reporter_tap&) = delete;
99
+
100
+ /**
101
+ * @brief Deleted move constructor to prevent moving.
102
+ */
103
+ test_reporter_tap (test_reporter_tap&&) = delete;
104
+
105
+ /**
106
+ * @brief Deleted copy assignment operator to prevent copying.
107
+ */
108
+ test_reporter_tap&
109
+ operator= (const test_reporter_tap&)
110
+ = delete;
111
+
112
+ /**
113
+ * @brief Deleted move assignment operator to prevent moving.
114
+ */
115
+ test_reporter_tap&
116
+ operator= (test_reporter_tap&&)
117
+ = delete;
118
+
119
+ /**
120
+ * @brief Destructor for the test_reporter_tap class.
121
+ */
122
+ ~test_reporter_tap () override = default;
123
+
124
+ /**
125
+ * @brief Inserts a line ending into the output buffer.
126
+ *
127
+ * @par Parameters
128
+ * None.
129
+ * @par Returns
130
+ * Nothing.
131
+ */
132
+ void
133
+ endline (void) override;
134
+
135
+ /**
136
+ * @brief Mark the beginning of a test case.
137
+ *
138
+ * @param name The name of the test case.
139
+ * @par Returns
140
+ * Nothing.
141
+ */
142
+ void
143
+ begin_test_case (const char* name) override;
144
+
145
+ /**
146
+ * @brief Mark the end of a test case.
147
+ *
148
+ * @param name The name of the test case.
149
+ * @par Returns
150
+ * Nothing.
151
+ */
152
+ void
153
+ end_test_case (const char* name) override;
154
+
155
+ /**
156
+ * @brief Mark the beginning of a test suite.
157
+ *
158
+ * @param name The name of the test suite.
159
+ * @par Returns
160
+ * Nothing.
161
+ */
162
+ void
163
+ begin_test_suite (const char* name) override;
164
+
165
+ /**
166
+ * @brief Mark the end of a test suite.
167
+ *
168
+ * @param suite Reference to the test suite base.
169
+ * @par Returns
170
+ * Nothing.
171
+ */
172
+ void
173
+ end_test_suite (test_suite_base& suite) override;
174
+
175
+ /**
176
+ * @brief Mark the beginning of a test.
177
+ *
178
+ * @param test_suites_count The number of test suites, or zero if unknown.
179
+ * @par Returns
180
+ * Nothing.
181
+ */
182
+ void
183
+ begin_test (size_t test_suites_count) override;
184
+
185
+ /**
186
+ * @brief Mark the end of a test.
187
+ *
188
+ * @param runner Reference to the test runner.
189
+ * @par Returns
190
+ * Nothing.
191
+ */
192
+ void
193
+ end_test (test_runner& runner) override;
194
+
195
+ /**
196
+ * @brief Flush the current buffered content.
197
+ *
198
+ * @par Parameters
199
+ * None.
200
+ * @par Returns
201
+ * Nothing.
202
+ */
203
+ void
204
+ flush (void) override;
205
+
206
+ /**
207
+ * @brief Output the current buffered content.
208
+ *
209
+ * @par Parameters
210
+ * None.
211
+ * @par Returns
212
+ * Nothing.
213
+ */
214
+ void
215
+ output (void) override;
216
+
217
+ protected:
218
+ /**
219
+ * @brief Outputs the prefix for a passing condition.
220
+ *
221
+ * @param message The message to display.
222
+ * @par Returns
223
+ * Nothing.
224
+ */
225
+ void
226
+ output_pass_prefix_ (std::string& message) override;
227
+
228
+ /**
229
+ * @brief Outputs the suffix for a passing condition.
230
+ *
231
+ * @par Parameters
232
+ * None.
233
+ * @par Returns
234
+ * Nothing.
235
+ */
236
+ void
237
+ output_pass_suffix_ (void) override;
238
+
239
+ /**
240
+ * @brief Outputs the prefix for a failing condition.
241
+ *
242
+ * @param message The message to display.
243
+ * @param hasExpression Whether the failure is associated with an
244
+ * expression.
245
+ * @param location The source location of the failure.
246
+ * @par Returns
247
+ * Nothing.
248
+ */
249
+ void
250
+ output_fail_prefix_ (std::string& message, const bool hasExpression,
251
+ const reflection::source_location& location) override;
252
+
253
+ /**
254
+ * @brief Outputs the suffix for a failing condition.
255
+ *
256
+ * @param location The source location of the failure.
257
+ * @param abort Whether to abort execution after failure.
258
+ * @par Returns
259
+ * Nothing.
260
+ */
261
+ void
262
+ output_fail_suffix_ (const reflection::source_location& location,
263
+ bool abort) override;
264
+ };
265
+
266
+ // --------------------------------------------------------------------------
267
+ } // namespace micro_os_plus::micro_test_plus
268
+
269
+ #if defined(__GNUC__)
270
+ #pragma GCC diagnostic pop
271
+ #endif
272
+
273
+ // ----------------------------------------------------------------------------
274
+
275
+ #endif // __cplusplus
276
+
277
+ // ----------------------------------------------------------------------------
278
+
279
+ #endif // MICRO_TEST_PLUS_TEST_REPORTER_TAP_H_
280
+
281
+ // ----------------------------------------------------------------------------