@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
@@ -1,12 +1,12 @@
1
1
  /*
2
2
  * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
- * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * 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.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * 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.
10
10
  *
11
11
  * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
12
  * released under the terms of the Boost Version 1.0 Software License,
@@ -15,6 +15,29 @@
15
15
 
16
16
  // ----------------------------------------------------------------------------
17
17
 
18
+ /**
19
+ * @file
20
+ * @brief C++ source file with implementations for the µTest++ test runner
21
+ * methods.
22
+ *
23
+ * @details
24
+ * This source file contains the core implementations for the test runner
25
+ * facilities of the µTest++ framework. It provides the logic for initialising
26
+ * the test environment, registering and managing test suites, handling
27
+ * command-line arguments, orchestrating test execution, and determining the
28
+ * overall test result. The implementation supports automated discovery and
29
+ * execution of test suites, flexible verbosity control, and robust mechanisms
30
+ * for aborting test execution in critical scenarios.
31
+ *
32
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
33
+ * namespace, ensuring clear separation from user code and minimising the risk
34
+ * of naming conflicts.
35
+ *
36
+ * This file must be included when building the µTest++ library.
37
+ */
38
+
39
+ // ----------------------------------------------------------------------------
40
+
18
41
  #if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
19
42
  #include <micro-os-plus/config.h>
20
43
  #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
@@ -37,6 +60,15 @@ namespace micro_os_plus::micro_test_plus
37
60
  {
38
61
  // --------------------------------------------------------------------------
39
62
 
63
+ /**
64
+ * @details
65
+ * The constructor initialises a new instance of the `test_runner` class,
66
+ * preparing the test runner for managing test suites and cases within the
67
+ * µTest++ framework. If tracing is enabled, it outputs the function
68
+ * signature for diagnostic purposes. This setup ensures the test runner is
69
+ * ready to coordinate the registration, execution, and reporting of tests
70
+ * across all test cases and folders.
71
+ */
40
72
  test_runner::test_runner ()
41
73
  {
42
74
  #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
@@ -48,6 +80,18 @@ namespace micro_os_plus::micro_test_plus
48
80
  #if defined(__clang__)
49
81
  #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
50
82
  #endif
83
+ /**
84
+ * @details
85
+ * This method initialises the test runner by capturing the command-line
86
+ * arguments and the default test suite name, configuring the framework for
87
+ * subsequent test execution. It parses the arguments to determine the
88
+ * desired verbosity level (normal, verbose, quiet, or silent) and applies
89
+ * this setting to the test reporter. The method also outputs build and
90
+ * environment information when appropriate, aiding diagnostics and
91
+ * transparency. Finally, it creates and registers the default test suite,
92
+ * preparing the framework to manage and execute all test cases and suites
93
+ * across the project’s folders.
94
+ */
51
95
  void
52
96
  test_runner::initialize (int argc, char* argv[], const char* name)
53
97
  {
@@ -173,6 +217,17 @@ namespace micro_os_plus::micro_test_plus
173
217
  return was_successful ? 0 : 1;
174
218
  }
175
219
 
220
+ /**
221
+ * @details
222
+ * This method registers a new test suite with the test runner. If the
223
+ * internal collection of test suites has not yet been created, it is
224
+ * initialised at this point. The provided test suite is then added to the
225
+ * collection, enabling the framework to manage and execute multiple test
226
+ * suites across different files and folders within the project.
227
+ *
228
+ * Called by test suite constructors to register themselves with the
229
+ * runner, enabling automatic management and execution.
230
+ */
176
231
  void
177
232
  test_runner::register_test_suite (test_suite_base* suite)
178
233
  {
@@ -187,6 +242,15 @@ namespace micro_os_plus::micro_test_plus
187
242
  suites_->push_back (suite);
188
243
  }
189
244
 
245
+ /**
246
+ * @details
247
+ * This method immediately terminates the process by invoking the standard C
248
+ * library `abort()` function. It is used to halt test execution in critical
249
+ * failure scenarios, ensuring that no further tests are run and that the
250
+ * cause of the failure can be promptly investigated. This approach provides
251
+ * a robust mechanism for enforcing strict test outcomes across all test
252
+ * cases and folders.
253
+ */
190
254
  void
191
255
  test_runner::abort (void)
192
256
  {
@@ -1,12 +1,12 @@
1
1
  /*
2
2
  * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
- * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * 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.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * 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.
10
10
  *
11
11
  * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
12
  * released under the terms of the Boost Version 1.0 Software License,
@@ -15,6 +15,34 @@
15
15
 
16
16
  // ----------------------------------------------------------------------------
17
17
 
18
+ /**
19
+ * @file
20
+ * @brief C++ source file with implementations for the µTest++ test suite
21
+ * methods.
22
+ *
23
+ * @details
24
+ * This source file contains the core implementations for the test suite
25
+ * facilities of the µTest++ framework. It provides the logic for constructing,
26
+ * registering, and managing test suites and their associated test cases. The
27
+ * implementation covers initialisation and clean-up routines, execution of
28
+ * test suites and test cases, tracking of successful and failed checks, and
29
+ * integration with the test reporter for structured output.
30
+ *
31
+ * The design ensures that test suites are non-copyable and non-movable,
32
+ * maintaining unique ownership and consistent state. Flexible support for
33
+ * callable objects enables a wide range of test suite definitions,
34
+ * facilitating expressive and maintainable test organisation across embedded
35
+ * and general C++ projects.
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
+ * This file must be included when building the µTest++ library.
42
+ */
43
+
44
+ // ----------------------------------------------------------------------------
45
+
18
46
  #if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
19
47
  #include <micro-os-plus/config.h>
20
48
  #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
@@ -34,6 +62,16 @@ namespace micro_os_plus::micro_test_plus
34
62
  {
35
63
  // --------------------------------------------------------------------------
36
64
 
65
+ /**
66
+ * @details
67
+ * The constructor initialises a new instance of the `test_suite_base` class
68
+ * with the specified name. It sets up the internal state required for
69
+ * managing test cases within the suite. If tracing is enabled, the function
70
+ * signature is output for diagnostic purposes. The default test suite does
71
+ * not require explicit registration, ensuring seamless integration within
72
+ * the µTest++ framework and supporting organised test management across all
73
+ * files and folders.
74
+ */
37
75
  test_suite_base::test_suite_base (const char* name)
38
76
  {
39
77
  #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
@@ -44,10 +82,26 @@ namespace micro_os_plus::micro_test_plus
44
82
  // The default test suite needs no registration.
45
83
  }
46
84
 
85
+ /**
86
+ * @details
87
+ * The destructor releases any resources associated with the
88
+ * `test_suite_base` instance. It ensures that the test suite is properly
89
+ * cleaned up after execution, supporting robust and reliable test management
90
+ * across all files and folders within the µTest++ framework.
91
+ */
47
92
  test_suite_base::~test_suite_base ()
48
93
  {
49
94
  }
50
95
 
96
+ /**
97
+ * @details
98
+ * This method executes the test suite by invoking its associated callable
99
+ * object. If tracing is enabled, the function signature is output for
100
+ * diagnostic purposes. The method ensures that all test cases grouped within
101
+ * the suite are executed in an organised manner, supporting comprehensive
102
+ * and structured testing across all files and folders within the µTest++
103
+ * framework.
104
+ */
51
105
  void
52
106
  test_suite_base::run ()
53
107
  {
@@ -56,6 +110,14 @@ namespace micro_os_plus::micro_test_plus
56
110
  #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
57
111
  }
58
112
 
113
+ /**
114
+ * @details
115
+ * This method marks the beginning of a test suite's execution. It resets the
116
+ * deferred begin flag and notifies the test reporter to start the suite,
117
+ * passing the suite's name. This ensures that test suite output is clearly
118
+ * delineated and properly initialised, supporting organised and readable
119
+ * reporting across all test cases and folders.
120
+ */
59
121
  void
60
122
  test_suite_base::begin_test_suite (void)
61
123
  {
@@ -64,6 +126,15 @@ namespace micro_os_plus::micro_test_plus
64
126
  reporter.begin_test_suite (name_);
65
127
  }
66
128
 
129
+ /**
130
+ * @details
131
+ * This method marks the end of a test suite's execution. If the suite's
132
+ * start was deferred, it ensures the suite is properly begun before
133
+ * finalising. The method then notifies the test reporter to conclude the
134
+ * suite, passing a reference to the suite instance. This guarantees that all
135
+ * results are accurately summarised and reported, supporting clear and
136
+ * organised test management across all test cases and folders.
137
+ */
67
138
  void
68
139
  test_suite_base::end_test_suite (void)
69
140
  {
@@ -74,6 +145,16 @@ namespace micro_os_plus::micro_test_plus
74
145
  reporter.end_test_suite (*this);
75
146
  }
76
147
 
148
+ /**
149
+ * @details
150
+ * This method marks the beginning of a test case within the suite. If the
151
+ * start of the suite was deferred, it ensures the suite is properly begun
152
+ * before proceeding. The method sets the current test case name, increments
153
+ * the total number of test cases, resets the current test case statistics,
154
+ * and notifies the test reporter to begin the test case. This approach
155
+ * guarantees that each test case is clearly identified, accurately tracked,
156
+ * and properly reported across all test cases and folders.
157
+ */
77
158
  void
78
159
  test_suite_base::begin_test_case (const char* name)
79
160
  {
@@ -90,12 +171,27 @@ namespace micro_os_plus::micro_test_plus
90
171
  reporter.begin_test_case (test_case_name_);
91
172
  }
92
173
 
174
+ /**
175
+ * @details
176
+ * This method marks the end of a test case within the suite. It notifies the
177
+ * test reporter to conclude the test case, passing the current test case
178
+ * name. This ensures that the results of the test case are accurately
179
+ * finalised and clearly reported, supporting organised and reliable test
180
+ * management across all test cases and folders.
181
+ */
93
182
  void
94
183
  test_suite_base::end_test_case (void)
95
184
  {
96
185
  reporter.end_test_case (test_case_name_);
97
186
  }
98
187
 
188
+ /**
189
+ * @details
190
+ * This method increments the count of successful checks for the test suite
191
+ * and the current test case. It ensures that each passing assertion is
192
+ * accurately recorded, supporting precise tracking and reporting of test
193
+ * outcomes across all test cases and folders.
194
+ */
99
195
  void
100
196
  test_suite_base::increment_successful (void)
101
197
  {
@@ -103,6 +199,13 @@ namespace micro_os_plus::micro_test_plus
103
199
  ++current_test_case.successful_checks;
104
200
  }
105
201
 
202
+ /**
203
+ * @details
204
+ * This method increments the count of failed checks for the test suite and
205
+ * the current test case. It ensures that each failing assertion is
206
+ * accurately recorded, supporting precise tracking and reporting of test
207
+ * outcomes across all test cases and folders.
208
+ */
106
209
  void
107
210
  test_suite_base::increment_failed (void)
108
211
  {
@@ -112,6 +215,14 @@ namespace micro_os_plus::micro_test_plus
112
215
 
113
216
  // ==========================================================================
114
217
 
218
+ /**
219
+ * @details
220
+ * This method executes the test suite by invoking the stored callable object
221
+ * associated with the suite. It ensures that all test cases registered
222
+ * within the suite are executed in sequence, supporting comprehensive and
223
+ * structured testing across all files and folders within the µTest++
224
+ * framework.
225
+ */
115
226
  void
116
227
  test_suite::run (void)
117
228
  {
@@ -119,6 +230,14 @@ namespace micro_os_plus::micro_test_plus
119
230
  callable_ ();
120
231
  }
121
232
 
233
+ /**
234
+ * @details
235
+ * The destructor releases any resources associated with the `test_suite`
236
+ * instance. If tracing is enabled, it outputs the function signature for
237
+ * diagnostic purposes. This ensures that the test suite is properly cleaned
238
+ * up after execution, supporting robust and reliable test management across
239
+ * all files and folders within the µTest++ framework.
240
+ */
122
241
  test_suite::~test_suite ()
123
242
  {
124
243
  #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)