@micro-os-plus/micro-test-plus 3.3.1 → 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 (65) hide show
  1. package/CHANGELOG.md +412 -2
  2. package/CMakeLists.txt +134 -28
  3. package/README.md +3 -2
  4. package/config/xcdl-build.json +11 -4
  5. package/include/micro-os-plus/micro-test-plus/README.md +6 -0
  6. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +267 -0
  7. package/include/micro-os-plus/micro-test-plus/detail.h +272 -1425
  8. package/include/micro-os-plus/micro-test-plus/exceptions.h +125 -0
  9. package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
  10. package/include/micro-os-plus/micro-test-plus/function-comparators.h +15 -7
  11. package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +66 -44
  12. package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → expression-formatter-inlines.h} +232 -198
  15. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +24 -20
  16. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +50 -31
  17. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +25 -19
  18. package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
  19. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +39 -21
  20. package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +205 -0
  21. package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +151 -0
  22. package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
  23. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +555 -0
  24. package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
  25. package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +231 -0
  26. package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
  27. package/include/micro-os-plus/micro-test-plus/literals.h +12 -17
  28. package/include/micro-os-plus/micro-test-plus/math.h +14 -6
  29. package/include/micro-os-plus/micro-test-plus/operators.h +53 -209
  30. package/include/micro-os-plus/micro-test-plus/reflection.h +8 -4
  31. package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +80 -74
  32. package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +77 -71
  33. package/include/micro-os-plus/micro-test-plus/reporter.h +619 -0
  34. package/include/micro-os-plus/micro-test-plus/runner-totals.h +250 -0
  35. package/include/micro-os-plus/micro-test-plus/runner.h +472 -0
  36. package/include/micro-os-plus/micro-test-plus/test.h +1013 -0
  37. package/include/micro-os-plus/micro-test-plus/timings.h +363 -0
  38. package/include/micro-os-plus/micro-test-plus/type-traits.h +223 -577
  39. package/include/micro-os-plus/micro-test-plus/utility.h +136 -0
  40. package/include/micro-os-plus/micro-test-plus.h +42 -236
  41. package/meson.build +11 -6
  42. package/package.json +11 -3
  43. package/src/deferred-reporter.cpp +137 -0
  44. package/src/expression-formatter.cpp +289 -0
  45. package/src/reflection.cpp +97 -0
  46. package/src/reporter-human.cpp +816 -0
  47. package/src/reporter-tap.cpp +772 -0
  48. package/src/reporter.cpp +481 -0
  49. package/src/runner-totals.cpp +98 -0
  50. package/src/runner.cpp +669 -0
  51. package/src/test.cpp +503 -0
  52. package/src/timings.cpp +210 -0
  53. package/src/utility.cpp +163 -0
  54. package/.cmake-format.yaml +0 -11
  55. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
  56. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +0 -115
  57. package/include/micro-os-plus/micro-test-plus/test-reporter.h +0 -846
  58. package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
  59. package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
  60. package/src/micro-test-plus.cpp +0 -316
  61. package/src/test-reporter-basic.cpp +0 -466
  62. package/src/test-reporter-tap.cpp +0 -530
  63. package/src/test-reporter.cpp +0 -399
  64. package/src/test-runner.cpp +0 -311
  65. package/src/test-suite.cpp +0 -304
@@ -1,281 +0,0 @@
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++ test runner.
21
- *
22
- * @details
23
- * This header provides the declarations for the test runner facilities used
24
- * within the µTest++ framework. It defines the interface for managing the
25
- * registration and execution of test suites, supporting automated discovery
26
- * and orchestration of tests across a project.
27
- *
28
- * The test runner is responsible for initialising the test environment,
29
- * registering test suites, managing command-line arguments, and determining
30
- * the overall test result via an exit code. It also provides mechanisms for
31
- * aborting test execution and retrieving the default suite name.
32
- *
33
- * All definitions reside within the
34
- * `micro_os_plus::micro_test_plus` namespace, ensuring clear
35
- * separation from user code and minimising the risk of naming conflicts.
36
- *
37
- * The header files are organised within the
38
- * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
39
- * modular codebase.
40
- *
41
- * This file is intended solely for internal use within the framework and
42
- * should not be included directly by user code.
43
- */
44
-
45
- #ifndef MICRO_TEST_PLUS_TEST_RUNNER_H_
46
- #define MICRO_TEST_PLUS_TEST_RUNNER_H_
47
-
48
- // ----------------------------------------------------------------------------
49
-
50
- #ifdef __cplusplus
51
-
52
- // ----------------------------------------------------------------------------
53
-
54
- #include <functional>
55
-
56
- #include <time.h>
57
-
58
- // ----------------------------------------------------------------------------
59
-
60
- #if defined(__GNUC__)
61
- #pragma GCC diagnostic push
62
- #pragma GCC diagnostic ignored "-Wpadded"
63
- #if defined(__clang__)
64
- #pragma clang diagnostic ignored "-Wc++98-compat"
65
- #endif
66
- #endif
67
-
68
- namespace micro_os_plus::micro_test_plus
69
- {
70
- // --------------------------------------------------------------------------
71
-
72
- // Forward definition.
73
- class test_suite_base;
74
-
75
- // --------------------------------------------------------------------------
76
-
77
- /**
78
- * @brief The test runner for the µTest++ framework.
79
- *
80
- * @details
81
- * The `test_runner` class is responsible for managing the registration and
82
- * execution of test suites within the µTest++ framework. It maintains a
83
- * collection of test suites, each of which registers itself automatically
84
- * upon construction, enabling seamless integration and execution of tests
85
- * across different components and folders of a project.
86
- *
87
- * The test runner provides methods for initialising the test environment,
88
- * registering test suites, retrieving the runner's name, and determining the
89
- * overall test result via an exit code. It also offers an abort mechanism
90
- * for terminating test execution in exceptional circumstances.
91
- *
92
- * All members and methods are defined within the
93
- * `micro_os_plus::micro_test_plus` namespace, ensuring clear separation from
94
- * user code and minimising the risk of naming conflicts.
95
- *
96
- * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
97
- */
98
- class test_runner
99
- {
100
- public:
101
- /**
102
- * @brief Default constructor for the test_runner class.
103
- *
104
- * @details
105
- * The rule of five is enforced to prevent accidental copying or moving.
106
- */
107
- test_runner ();
108
-
109
- /**
110
- * @brief Deleted copy constructor to prevent copying.
111
- */
112
- test_runner (const test_runner&) = delete;
113
-
114
- /**
115
- * @brief Deleted move constructor to prevent moving.
116
- */
117
- test_runner (test_runner&&) = delete;
118
-
119
- /**
120
- * @brief Deleted copy assignment operator to prevent copying.
121
- */
122
- test_runner&
123
- operator= (const test_runner&)
124
- = delete;
125
-
126
- /**
127
- * @brief Deleted move assignment operator to prevent moving.
128
- */
129
- test_runner&
130
- operator= (test_runner&&)
131
- = delete;
132
-
133
- /**
134
- * @brief Destructor for the test_runner class.
135
- */
136
- ~test_runner () = default;
137
-
138
- /**
139
- * @brief Initialises the test runner with command-line arguments and an
140
- * optional suite name.
141
- *
142
- * @param argc The argument count from main().
143
- * @param argv The argument vector from main().
144
- * @param name The name of the default test suite.
145
- * @par Returns
146
- * Nothing.
147
- */
148
- void
149
- initialize (int argc, char* argv[], const char* name);
150
-
151
- /**
152
- * @brief Returns 0 if all tests were successful, 1 otherwise.
153
- *
154
- * @par Parameters
155
- * None.
156
- * @return Integer exit code representing the overall test result.
157
- */
158
- int
159
- exit_code (void);
160
-
161
- /**
162
- * @brief Registers a test suite with the runner.
163
- *
164
- * @param suite Pointer to the test suite to register.
165
- * @par Returns
166
- * Nothing.
167
- */
168
- void
169
- register_test_suite (test_suite_base* suite);
170
-
171
- size_t
172
- test_suites_count (void)
173
- {
174
- return (test_suites != nullptr) ? test_suites->size () + 1 : 1;
175
- }
176
-
177
- /**
178
- * @brief Retrieves the name of the default test suite.
179
- *
180
- * @par Parameters
181
- * None.
182
- * @return The name of the default test suite as a constant character
183
- * pointer.
184
- */
185
- constexpr const char*
186
- name (void)
187
- {
188
- return default_suite_name_;
189
- }
190
-
191
- /**
192
- * @brief Aborts test execution immediately.
193
- *
194
- * @par Parameters
195
- * None.
196
- * @par Returns
197
- * Nothing.
198
- */
199
- [[noreturn]] void
200
- abort (void);
201
-
202
- // ------------------------------------------------------------------------
203
- public:
204
- /**
205
- * @brief Pointer to the array of registered test suites.
206
- *
207
- * @details
208
- * Statically initialised to zero as BSS, such that test suites defined as
209
- * static objects in different compilation units can be automatically
210
- * executed.
211
- */
212
- std::vector<test_suite_base*>* test_suites; // DO NOT INITIALISE!
213
-
214
- struct
215
- {
216
- /**
217
- * @brief Total number of successful checks in the test suite.
218
- */
219
- size_t successful_checks = 0;
220
-
221
- /**
222
- * @brief Total number of failed checks in the test suite.
223
- */
224
- size_t failed_checks = 0;
225
-
226
- /**
227
- * @brief Total number of test cases in the test suite.
228
- */
229
- size_t test_cases_count = 0;
230
- } totals;
231
-
232
- #if defined(_WIN32) || defined(CLOCK_MONOTONIC)
233
- /**
234
- * @brief The timestamp recorded at the beginning of the test suite.
235
- */
236
- timespec begin_time{};
237
-
238
- /**
239
- * @brief The timestamp recorded at the end of the test suite.
240
- */
241
- timespec end_time{};
242
- #endif
243
-
244
- /**
245
- * @brief Pointer to the default test suite which groups the main tests.
246
- */
247
- test_suite_base* default_test_suite = nullptr;
248
-
249
- protected:
250
- /**
251
- * @brief Stores the argument count passed to the test runner.
252
- */
253
- int argc_ = 0;
254
-
255
- /**
256
- * @brief Stores the argument vector passed to the test runner.
257
- */
258
- char** argv_ = nullptr;
259
-
260
- /**
261
- * @brief The name of the default test suite.
262
- */
263
- const char* default_suite_name_ = "Test";
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_RUNNER_H_
280
-
281
- // ----------------------------------------------------------------------------