@micro-os-plus/micro-test-plus 3.2.0 → 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 (42) hide show
  1. package/.cmake-format.yaml +11 -0
  2. package/CHANGELOG.md +502 -11
  3. package/CMakeLists.txt +33 -32
  4. package/LICENSE +1 -1
  5. package/README.md +15 -14
  6. package/config/xcdl-build.json +32 -0
  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 +171 -554
  26. package/meson.build +6 -7
  27. package/package.json +40 -32
  28. package/src/micro-test-plus.cpp +143 -42
  29. package/src/test-reporter.cpp +350 -9
  30. package/src/test-runner.cpp +77 -14
  31. package/src/test-suite.cpp +132 -14
  32. package/LICENSE-Boost +0 -23
  33. package/include/micro-os-plus/detail.h +0 -766
  34. package/include/micro-os-plus/inlines.h +0 -204
  35. package/include/micro-os-plus/literals.h +0 -513
  36. package/include/micro-os-plus/math.h +0 -205
  37. package/include/micro-os-plus/reflection.h +0 -139
  38. package/include/micro-os-plus/test-reporter-inlines.h +0 -231
  39. package/include/micro-os-plus/test-reporter.h +0 -357
  40. package/include/micro-os-plus/test-runner.h +0 -133
  41. package/include/micro-os-plus/test-suite.h +0 -307
  42. package/include/micro-os-plus/type-traits.h +0 -390
@@ -1,17 +1,39 @@
1
1
  /*
2
- * This file is part of the µOS++ distribution.
3
- * (https://github.com/micro-os-plus/)
4
- * Copyright (c) 2021 Liviu Ionescu.
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.
5
4
  *
6
- * Permission to use, copy, modify, and/or distribute this software
7
- * 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.
8
7
  *
9
- * If a copy of the license was not distributed with this file, it can
10
- * 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.
11
10
  *
12
11
  * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
13
12
  * released under the terms of the Boost Version 1.0 Software License,
14
- * which can be obtained from <https://www.boost.org/LICENSE_1_0.txt>.
13
+ * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
+ */
15
+
16
+ // ----------------------------------------------------------------------------
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.
15
37
  */
16
38
 
17
39
  // ----------------------------------------------------------------------------
@@ -38,23 +60,44 @@ namespace micro_os_plus::micro_test_plus
38
60
  {
39
61
  // --------------------------------------------------------------------------
40
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
+ */
41
72
  test_runner::test_runner ()
42
73
  {
43
- #if defined(MICRO_TEST_PLUS_TRACE)
74
+ #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
44
75
  printf ("%s\n", __PRETTY_FUNCTION__);
45
- #endif // MICRO_TEST_PLUS_TRACE
76
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
46
77
  }
47
78
 
48
79
  #pragma GCC diagnostic push
49
80
  #if defined(__clang__)
50
81
  #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
51
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
+ */
52
95
  void
53
96
  test_runner::initialize (int argc, char* argv[], const char* name)
54
97
  {
55
- #if defined(MICRO_TEST_PLUS_TRACE)
98
+ #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
56
99
  printf ("%s\n", __PRETTY_FUNCTION__);
57
- #endif // MICRO_TEST_PLUS_TRACE
100
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
58
101
 
59
102
  argc_ = argc;
60
103
  argv_ = argv;
@@ -174,12 +217,23 @@ namespace micro_os_plus::micro_test_plus
174
217
  return was_successful ? 0 : 1;
175
218
  }
176
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
+ */
177
231
  void
178
232
  test_runner::register_test_suite (test_suite_base* suite)
179
233
  {
180
- #if 0 // defined(MICRO_TEST_PLUS_TRACE)
234
+ #if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
181
235
  printf ("%s\n", __PRETTY_FUNCTION__);
182
- #endif // MICRO_TEST_PLUS_TRACE
236
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
183
237
 
184
238
  if (suites_ == nullptr)
185
239
  {
@@ -188,6 +242,15 @@ namespace micro_os_plus::micro_test_plus
188
242
  suites_->push_back (suite);
189
243
  }
190
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
+ */
191
254
  void
192
255
  test_runner::abort (void)
193
256
  {
@@ -1,17 +1,44 @@
1
1
  /*
2
- * This file is part of the µOS++ distribution.
3
- * (https://github.com/micro-os-plus/)
4
- * Copyright (c) 2021 Liviu Ionescu.
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.
5
4
  *
6
- * Permission to use, copy, modify, and/or distribute this software
7
- * 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.
8
7
  *
9
- * If a copy of the license was not distributed with this file, it can
10
- * 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.
11
10
  *
12
11
  * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
13
12
  * released under the terms of the Boost Version 1.0 Software License,
14
- * which can be obtained from <https://www.boost.org/LICENSE_1_0.txt>.
13
+ * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
+ */
15
+
16
+ // ----------------------------------------------------------------------------
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.
15
42
  */
16
43
 
17
44
  // ----------------------------------------------------------------------------
@@ -35,28 +62,62 @@ namespace micro_os_plus::micro_test_plus
35
62
  {
36
63
  // --------------------------------------------------------------------------
37
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
+ */
38
75
  test_suite_base::test_suite_base (const char* name)
39
76
  {
40
- #if defined(MICRO_TEST_PLUS_TRACE)
77
+ #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
41
78
  printf ("%s\n", __PRETTY_FUNCTION__);
42
- #endif // MICRO_TEST_PLUS_TRACE
79
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
43
80
 
44
81
  name_ = name;
45
82
  // The default test suite needs no registration.
46
83
  }
47
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
+ */
48
92
  test_suite_base::~test_suite_base ()
49
93
  {
50
94
  }
51
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
+ */
52
105
  void
53
106
  test_suite_base::run ()
54
107
  {
55
- #if defined(MICRO_TEST_PLUS_TRACE)
108
+ #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
56
109
  printf ("%s\n", __PRETTY_FUNCTION__);
57
- #endif // MICRO_TEST_PLUS_TRACE
110
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
58
111
  }
59
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
+ */
60
121
  void
61
122
  test_suite_base::begin_test_suite (void)
62
123
  {
@@ -65,6 +126,15 @@ namespace micro_os_plus::micro_test_plus
65
126
  reporter.begin_test_suite (name_);
66
127
  }
67
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
+ */
68
138
  void
69
139
  test_suite_base::end_test_suite (void)
70
140
  {
@@ -75,6 +145,16 @@ namespace micro_os_plus::micro_test_plus
75
145
  reporter.end_test_suite (*this);
76
146
  }
77
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
+ */
78
158
  void
79
159
  test_suite_base::begin_test_case (const char* name)
80
160
  {
@@ -91,12 +171,27 @@ namespace micro_os_plus::micro_test_plus
91
171
  reporter.begin_test_case (test_case_name_);
92
172
  }
93
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
+ */
94
182
  void
95
183
  test_suite_base::end_test_case (void)
96
184
  {
97
185
  reporter.end_test_case (test_case_name_);
98
186
  }
99
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
+ */
100
195
  void
101
196
  test_suite_base::increment_successful (void)
102
197
  {
@@ -104,6 +199,13 @@ namespace micro_os_plus::micro_test_plus
104
199
  ++current_test_case.successful_checks;
105
200
  }
106
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
+ */
107
209
  void
108
210
  test_suite_base::increment_failed (void)
109
211
  {
@@ -113,6 +215,14 @@ namespace micro_os_plus::micro_test_plus
113
215
 
114
216
  // ==========================================================================
115
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
+ */
116
226
  void
117
227
  test_suite::run (void)
118
228
  {
@@ -120,11 +230,19 @@ namespace micro_os_plus::micro_test_plus
120
230
  callable_ ();
121
231
  }
122
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
+ */
123
241
  test_suite::~test_suite ()
124
242
  {
125
- #if defined(MICRO_TEST_PLUS_TRACE)
243
+ #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
126
244
  printf ("%s\n", __PRETTY_FUNCTION__);
127
- #endif // MICRO_TEST_PLUS_TRACE
245
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
128
246
  }
129
247
 
130
248
  // --------------------------------------------------------------------------
package/LICENSE-Boost DELETED
@@ -1,23 +0,0 @@
1
- Boost Software License - Version 1.0 - August 17th, 2003
2
-
3
- Permission is hereby granted, free of charge, to any person or organization
4
- obtaining a copy of the software and accompanying documentation covered by
5
- this license (the "Software") to use, reproduce, display, distribute,
6
- execute, and transmit the Software, and to prepare derivative works of the
7
- Software, and to permit third-parties to whom the Software is furnished to
8
- do so, all subject to the following:
9
-
10
- The copyright notices in the Software and this entire statement, including
11
- the above license grant, this restriction and the following disclaimer,
12
- must be included in all copies of the Software, in whole or in part, and
13
- all derivative works of the Software, unless such copies or derivative
14
- works are solely in the form of machine-executable object code generated by
15
- a source language processor.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
- DEALINGS IN THE SOFTWARE.