@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
package/meson.build CHANGED
@@ -1,14 +1,13 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  #
3
- # This file is part of the µOS++ distribution.
4
- # (https://github.com/micro-os-plus/)
5
- # Copyright (c) 2022 Liviu Ionescu
3
+ # This file is part of the µOS++ project (https://micro-os-plus.github.io/).
4
+ # Copyright (c) 2022-2026 Liviu Ionescu. All rights reserved.
6
5
  #
7
- # Permission to use, copy, modify, and/or distribute this software
8
- # for any purpose is hereby granted, under the terms of the MIT license.
6
+ # Permission to use, copy, modify, and/or distribute this software for any
7
+ # purpose is hereby granted, under the terms of the MIT license.
9
8
  #
10
- # If a copy of the license was not distributed with this file, it can
11
- # be obtained from https://opensource.org/licenses/MIT/.
9
+ # If a copy of the license was not distributed with this file, it can be
10
+ # obtained from https://opensource.org/licenses/mit.
12
11
  #
13
12
  # -----------------------------------------------------------------------------
14
13
 
package/package.json CHANGED
@@ -1,25 +1,17 @@
1
1
  {
2
2
  "name": "@micro-os-plus/micro-test-plus",
3
- "version": "3.2.0",
3
+ "version": "3.2.3",
4
4
  "description": "A source code library with µTest++, a lightweight testing framework for embedded platforms",
5
- "main": "",
6
- "scripts": {
7
- "postversion": "git push origin --all && git push origin --tags"
8
- },
9
5
  "repository": {
10
6
  "type": "git",
11
- "url": "https://github.com/micro-os-plus/micro-test-plus-xpack.git"
12
- },
13
- "homepage": "https://micro-os-plus.github.io/micro-test-plus-xpack",
14
- "bugs": {
15
- "url": "https://github.com/micro-os-plus/micro-test-plus-xpack/issues"
7
+ "url": "git+https://github.com/micro-os-plus/micro-test-plus-xpack.git"
16
8
  },
17
9
  "keywords": [
18
10
  "xpack",
11
+ "micro-os-plus",
19
12
  "c++",
20
13
  "testing",
21
- "framework",
22
- "micro-os-plus"
14
+ "framework"
23
15
  ],
24
16
  "author": {
25
17
  "name": "Liviu Ionescu",
@@ -27,29 +19,45 @@
27
19
  "url": "https://github.com/ilg-ul"
28
20
  },
29
21
  "license": "MIT",
30
- "config": {},
22
+ "bugs": {
23
+ "url": "https://github.com/micro-os-plus/micro-test-plus-xpack/issues"
24
+ },
25
+ "homepage": "https://micro-os-plus.github.io/micro-test-plus-xpack/",
26
+ "homepagePreview": "https://micro-os-plus.github.io/micro-test-plus-xpack-webpreview/",
27
+ "$dependenciesUrls": {
28
+ "del-cli": "https://www.npmjs.com/package/del-cli",
29
+ "json": "https://www.npmjs.com/package/json",
30
+ "liquidjs": "https://www.npmjs.com/package/liquidjs"
31
+ },
31
32
  "dependencies": {},
32
- "bundleDependencies": [],
33
- "$devDependenciesUrls": [
34
- "https://www.npmjs.com/package/del-cli"
35
- ],
36
33
  "devDependencies": {
37
- "del-cli": "^5.1.0"
34
+ "@xpack/npm-packages-helper": "github:xpack/npm-packages-helper",
35
+ "del-cli": "^7.0.0",
36
+ "json": "^11.0.0",
37
+ "liquidjs": "^10.25.0"
38
+ },
39
+ "scripts": {
40
+ "generate-top-commons": "bash node_modules/@xpack/npm-packages-helper/maintenance-scripts/generate-top-commons.sh --micro-os-plus",
41
+ "npm-install": "npm install",
42
+ "npm-link-helpers": "npm link @xpack/npm-packages-helper",
43
+ "npm-outdated": "npm outdated",
44
+ "npm-ci": "npm ci",
45
+ "npm-pack": "npm pack",
46
+ "npm-link": "npm link",
47
+ "git-log": "git log --pretty='%cd * %h %s' --date=short",
48
+ "git-pull-helper": "git -C ${HOME}/Work/micro-os-plus/build-helper-xpack.git pull",
49
+ "deep-clean": "del-cli node_modules package-lock.json *.tgz",
50
+ "postversion": "git push origin --all && git push origin --tags"
38
51
  },
39
52
  "xpack": {
40
- "minimumXpmRequired": "0.16.2",
41
- "actions": {
42
- "deep-clean": "del-cli node_modules package-lock.json",
43
- "npm-install": "npm install",
44
- "git-log": "git log --pretty='%cd * %h %s' --date=short",
45
- "npm-pack": "npm pack",
46
- "npm-version-patch": "npm version patch",
47
- "npm-version-minor": "npm version minor",
48
- "npm-version": "echo $(which node) $(node --version) && echo $(which npm) $(npm --version)"
49
- },
50
- "dependencies": {},
51
- "devDependencies": {},
52
- "properties": {},
53
- "buildConfigurations": {}
53
+ "minimumXpmRequired": "0.20.8"
54
+ },
55
+ "topConfig": {
56
+ "descriptiveName": "µTest++ Testing Framework",
57
+ "permalinkName": "micro-test-plus",
58
+ "useDoxygen": "true"
59
+ },
60
+ "engines": {
61
+ "node": ">=20.0"
54
62
  }
55
63
  }
@@ -1,17 +1,41 @@
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++ methods.
21
+ *
22
+ * @details
23
+ * This source file contains the core implementations for the µTest++ testing
24
+ * framework, including initialisation and shutdown routines, utility
25
+ * functions, and the management of global framework state. It provides the
26
+ * logic for setting up the test environment, registering and executing test
27
+ * suites, reporting results, and supporting utility operations such as file
28
+ * name extraction and pattern-based string matching.
29
+ *
30
+ * All definitions are contained within the `micro_os_plus::micro_test_plus`
31
+ * namespace and its nested namespaces, ensuring clear separation from user
32
+ * code and minimising the risk of naming conflicts.
33
+ *
34
+ * The implementation is optimised for embedded environments, avoiding heavy
35
+ * dependencies and providing lightweight, efficient mechanisms for test
36
+ * execution and reporting.
37
+ *
38
+ * This file must be included when building the µTest++ library.
15
39
  */
16
40
 
17
41
  // ----------------------------------------------------------------------------
@@ -43,20 +67,20 @@ namespace micro_os_plus::micro_test_plus
43
67
 
44
68
  /**
45
69
  * @details
46
- * All tests include a default test suite, which runs the test cases
47
- * defined in the main function.
48
- *
49
- * This function forwards the process arguments to the test framework
50
- * and initialises the runner.
70
+ * The `initialize` function sets up the µTest++ testing framework, preparing
71
+ * it for test execution. It processes command-line arguments, configures the
72
+ * test environment, and establishes the default test suite name. This
73
+ * function should be called at the beginning of the test programme,
74
+ * typically from the `main()` function, to ensure proper initialisation of
75
+ * all framework components.
51
76
  *
52
- * The name is used to identify the default test suite.
53
- *
54
- * The arguments can be used to control the verbosity level.
77
+ * The provided arguments may be used to configure verbosity or other
78
+ * run-time options for the test session.
55
79
  */
56
80
  void
57
81
  initialize (int argc, char* argv[], const char* name)
58
82
  {
59
- #if defined(MICRO_TEST_PLUS_TRACE)
83
+ #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
60
84
  printf ("%s\n", __PRETTY_FUNCTION__);
61
85
  #endif
62
86
  runner.initialize (argc, argv, name);
@@ -64,15 +88,21 @@ namespace micro_os_plus::micro_test_plus
64
88
 
65
89
  /**
66
90
  * @details
67
- * In addition to the test cases defined in `main()`, there can be
68
- * more separate **test suites**, defined as static objects in the same
69
- * file or in other files,
70
- * and self-registered via the static constructors mechanism.
91
+ * In addition to the test cases defined in `main()`, additional test suites
92
+ * may be declared as static objects either within the same file or in other
93
+ * files, and are automatically registered via the static constructors
94
+ * mechanism.
95
+ *
96
+ * The `exit_code` function finalises the execution of all registered test
97
+ * suites and test cases within the µTest++ framework, and returns an
98
+ * appropriate exit code to the operating system. This function should be
99
+ * called at the end of the test program, typically from the `main()`
100
+ * function, to ensure that all results are properly reported and the correct
101
+ * status is communicated.
71
102
  *
72
- * This function triggers the execution of the globally
73
- * registered test suites
74
- * (if any) and returns the test result as the process exit code
75
- * (0 = success).
103
+ * The returned value indicates the overall success or failure of the test
104
+ * run, allowing integration with build systems and continuous integration
105
+ * environments.
76
106
  */
77
107
  int
78
108
  exit_code (void)
@@ -85,6 +115,15 @@ namespace micro_os_plus::micro_test_plus
85
115
  namespace reflection
86
116
  {
87
117
 
118
+ /**
119
+ * @details
120
+ * This function extracts the short name from a given file path by locating
121
+ * the final folder separator ('/'). If a separator is found, it returns a
122
+ * pointer to the character immediately following it, effectively providing
123
+ * the file or folder name. If no separator is present, the original input
124
+ * string is returned. This utility is useful for reporting concise file or
125
+ * folder names in test output.
126
+ */
88
127
  const char*
89
128
  short_name (const char* name)
90
129
  {
@@ -104,21 +143,30 @@ namespace micro_os_plus::micro_test_plus
104
143
 
105
144
  namespace utility
106
145
  {
107
- /**
108
- * @details
109
- * For tests comparing strings, in addition to exact matches,
110
- * it is also possible to check matches with patterns like `*`
111
- * (for any characters) and `?` (for a single character)
112
- *
113
- * @par Examples
114
- *
115
- * ```cpp
116
- * namespace mt = micro_os_plus::micro_test_plus;
117
- *
118
- * mt::expect (mt::utility::is_match ("abc", "a?c")) << "abc matches a?c";
119
- * mt::expect (mt::utility::is_match ("abc", "a*c")) << "abc matches a*c";
120
- * ```
121
- */
146
+ #if defined(__clang__)
147
+ #pragma clang diagnostic push
148
+ #pragma clang diagnostic ignored "-Wdocumentation"
149
+ #endif
150
+ /**
151
+ * @details
152
+ * This function enables pattern-based string comparison for tests, supporting
153
+ * both exact matches and wildcard patterns. The pattern may include `*` to
154
+ * match any sequence of characters and `?` to match any single character. This
155
+ * allows for flexible validation of string content in test assertions,
156
+ * accommodating variable or partially known values.
157
+ *
158
+ * @par Examples
159
+ *
160
+ * @code{.cpp}
161
+ * namespace mt = micro_os_plus::micro_test_plus;
162
+ *
163
+ * mt::expect (mt::utility::is_match ("abc", "a?c")) << "abc matches a?c";
164
+ * mt::expect (mt::utility::is_match ("abc", "a*c")) << "abc matches a*c";
165
+ * @endcode
166
+ */
167
+ #if defined(__clang__)
168
+ #pragma clang diagnostic pop
169
+ #endif
122
170
  [[nodiscard]] bool
123
171
  is_match (std::string_view input, std::string_view pattern)
124
172
  {
@@ -158,6 +206,15 @@ namespace micro_os_plus::micro_test_plus
158
206
 
159
207
  namespace detail
160
208
  {
209
+ /**
210
+ * @details
211
+ * This constructor updates the current test suite's statistics based on
212
+ * the outcome of the test expression. If the evaluated value is true, the
213
+ * count of successful tests is incremented; otherwise, the count of failed
214
+ * tests is incremented. The source location is recorded for reporting
215
+ * purposes, enabling precise identification of the test case within the
216
+ * relevant file or folder.
217
+ */
161
218
  deferred_reporter_base::deferred_reporter_base (
162
219
  bool value, const reflection::source_location location)
163
220
  : value_{ value }, location_{ location }
@@ -172,11 +229,19 @@ namespace micro_os_plus::micro_test_plus
172
229
  }
173
230
  }
174
231
 
232
+ /**
233
+ * @details
234
+ * The destructor ensures that if an abort condition is set and the test
235
+ * expression has failed, the test output is flushed and the process is
236
+ * terminated. This mechanism guarantees immediate feedback and halts
237
+ * further execution upon critical test failures, aiding in rapid
238
+ * identification and resolution of issues during test runs.
239
+ */
175
240
  deferred_reporter_base::~deferred_reporter_base ()
176
241
  {
177
- #if 0 // defined(MICRO_TEST_PLUS_TRACE)
242
+ #if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
178
243
  printf ("%s\n", __PRETTY_FUNCTION__);
179
- #endif // MICRO_TEST_PLUS_TRACE
244
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
180
245
 
181
246
  if (abort_ && !value_)
182
247
  {
@@ -199,9 +264,45 @@ namespace micro_os_plus::micro_test_plus
199
264
  #endif
200
265
 
201
266
  // Static instances;
267
+ /**
268
+ * @brief Global instance of `test_runner`.
269
+ *
270
+ * @details
271
+ * This global instance of `test_runner` manages the lifecycle of test suites
272
+ * and test cases within the µTest++ framework. It is responsible for
273
+ * initialising the test environment, registering test suites, executing
274
+ * tests, and collecting results. By maintaining a single shared runner, the
275
+ * framework ensures consistent test execution and reporting across all test
276
+ * cases and folders.
277
+ */
202
278
  test_runner runner;
279
+
280
+ /**
281
+ * @brief Global instance of `test_reporter`.
282
+ *
283
+ * @details
284
+ * This global instance of `test_reporter` is responsible for collecting,
285
+ * formatting, and outputting the results of test execution within the
286
+ * µTest++ framework. It manages the reporting of test outcomes, including
287
+ * successes and failures, and ensures that all relevant information is
288
+ * presented clearly to the user. By maintaining a single shared reporter,
289
+ * the framework provides consistent and centralised reporting across all
290
+ * test cases and folders.
291
+ */
203
292
  test_reporter reporter;
204
293
 
294
+ /**
295
+ * @brief Global pointer references the currently active test suite.
296
+ *
297
+ * @details
298
+ * This global pointer references the currently active test suite within the
299
+ * µTest++ framework. It is used to track and update the state of the test
300
+ * suite during test execution, including recording test results and
301
+ * statistics. By maintaining a pointer to the current test suite, the
302
+ * framework ensures accurate association of test outcomes with their
303
+ * respective suites, supporting clear and organised reporting across all
304
+ * test cases and folders.
305
+ */
205
306
  test_suite_base* current_test_suite;
206
307
 
207
308
  #if defined(__GNUC__)