@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
package/meson.build CHANGED
@@ -1,13 +1,13 @@
1
1
  # -----------------------------------------------------------------------------
2
2
  #
3
3
  # This file is part of the µOS++ project (https://micro-os-plus.github.io/).
4
- # Copyright (c) 2022 Liviu Ionescu. All rights reserved.
4
+ # Copyright (c) 2022-2026 Liviu Ionescu. All rights reserved.
5
5
  #
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.
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.
8
8
  #
9
- # If a copy of the license was not distributed with this file, it can
10
- # 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.
11
11
  #
12
12
  # -----------------------------------------------------------------------------
13
13
 
package/package.json CHANGED
@@ -1,31 +1,11 @@
1
1
  {
2
2
  "name": "@micro-os-plus/micro-test-plus",
3
- "version": "3.2.2",
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
- "generate-top-commons": "bash node_modules/@xpack/npm-packages-helper/maintenance-scripts/generate-top-commons.sh --micro-os-plus",
8
- "npm-install": "npm install",
9
- "npm-link-helpers": "npm link @xpack/npm-packages-helper @xpack/docusaurus-template-liquid",
10
- "npm-outdated": "npm outdated",
11
- "npm-pack": "npm pack",
12
- "npm-link": "npm link",
13
- "npm-version-patch": "npm version patch",
14
- "npm-version-minor": "npm version minor",
15
- "git-log": "git log --pretty='%cd * %h %s' --date=short",
16
- "git-pull-helper": "git -C ${HOME}/Work/micro-os-plus/build-helper-xpack.git pull",
17
- "deep-clean": "del-cli node_modules package-lock.json *.tgz",
18
- "postversion": "git push origin --all && git push origin --tags"
19
- },
20
5
  "repository": {
21
6
  "type": "git",
22
7
  "url": "git+https://github.com/micro-os-plus/micro-test-plus-xpack.git"
23
8
  },
24
- "bugs": {
25
- "url": "https://github.com/micro-os-plus/micro-test-plus-xpack/issues"
26
- },
27
- "homepage": "https://micro-os-plus.github.io/micro-test-plus-xpack/",
28
- "homepagePreview": "https://micro-os-plus.github.io/micro-test-plus-xpack-webpreview/",
29
9
  "keywords": [
30
10
  "xpack",
31
11
  "micro-os-plus",
@@ -39,23 +19,38 @@
39
19
  "url": "https://github.com/ilg-ul"
40
20
  },
41
21
  "license": "MIT",
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
+ },
42
32
  "dependencies": {},
43
- "$devDependenciesUrls": [
44
- "https://www.npmjs.com/package/del-cli",
45
- "https://www.npmjs.com/package/json",
46
- "https://www.npmjs.com/package/liquidjs"
47
- ],
48
33
  "devDependencies": {
49
- "del-cli": "^6.0.0",
34
+ "@xpack/npm-packages-helper": "github:xpack/npm-packages-helper",
35
+ "del-cli": "^7.0.0",
50
36
  "json": "^11.0.0",
51
- "liquidjs": "^10.19.1"
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"
52
51
  },
53
52
  "xpack": {
54
- "minimumXpmRequired": "0.20.8",
55
- "dependencies": {},
56
- "devDependencies": {},
57
- "properties": {},
58
- "buildConfigurations": {}
53
+ "minimumXpmRequired": "0.20.8"
59
54
  },
60
55
  "topConfig": {
61
56
  "descriptiveName": "µTest++ Testing Framework",
@@ -63,6 +58,6 @@
63
58
  "useDoxygen": "true"
64
59
  },
65
60
  "engines": {
66
- "node": " >=18.0.0"
61
+ "node": ">=20.0"
67
62
  }
68
63
  }
@@ -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,31 @@
15
15
 
16
16
  // ----------------------------------------------------------------------------
17
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.
39
+ */
40
+
41
+ // ----------------------------------------------------------------------------
42
+
18
43
  #if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
19
44
  #include <micro-os-plus/config.h>
20
45
  #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
@@ -42,15 +67,15 @@ namespace micro_os_plus::micro_test_plus
42
67
 
43
68
  /**
44
69
  * @details
45
- * All tests include a default test suite, which runs the test cases
46
- * defined in the main function.
47
- *
48
- * This function forwards the process arguments to the test framework
49
- * and initialises the runner.
50
- *
51
- * The name is used to identify the default test suite.
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.
52
76
  *
53
- * 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.
54
79
  */
55
80
  void
56
81
  initialize (int argc, char* argv[], const char* name)
@@ -63,15 +88,21 @@ namespace micro_os_plus::micro_test_plus
63
88
 
64
89
  /**
65
90
  * @details
66
- * In addition to the test cases defined in `main()`, there can be
67
- * more separate **test suites**, defined as static objects in the same
68
- * file or in other files,
69
- * 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.
70
95
  *
71
- * This function triggers the execution of the globally
72
- * registered test suites
73
- * (if any) and returns the test result as the process exit code
74
- * (0 = success).
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.
102
+ *
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.
75
106
  */
76
107
  int
77
108
  exit_code (void)
@@ -84,6 +115,15 @@ namespace micro_os_plus::micro_test_plus
84
115
  namespace reflection
85
116
  {
86
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
+ */
87
127
  const char*
88
128
  short_name (const char* name)
89
129
  {
@@ -107,20 +147,23 @@ namespace micro_os_plus::micro_test_plus
107
147
  #pragma clang diagnostic push
108
148
  #pragma clang diagnostic ignored "-Wdocumentation"
109
149
  #endif
110
- /**
111
- * @details
112
- * For tests comparing strings, in addition to exact matches,
113
- * it is also possible to check matches with patterns like `*`
114
- * (for any characters) and `?` (for a single character)
115
- *
116
- * @par Examples
117
- * ```cpp
118
- * namespace mt = micro_os_plus::micro_test_plus;
119
- *
120
- * mt::expect (mt::utility::is_match ("abc", "a?c")) << "abc matches a?c";
121
- * mt::expect (mt::utility::is_match ("abc", "a*c")) << "abc matches a*c";
122
- * ```
123
- */
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
+ */
124
167
  #if defined(__clang__)
125
168
  #pragma clang diagnostic pop
126
169
  #endif
@@ -163,6 +206,15 @@ namespace micro_os_plus::micro_test_plus
163
206
 
164
207
  namespace detail
165
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
+ */
166
218
  deferred_reporter_base::deferred_reporter_base (
167
219
  bool value, const reflection::source_location location)
168
220
  : value_{ value }, location_{ location }
@@ -177,6 +229,14 @@ namespace micro_os_plus::micro_test_plus
177
229
  }
178
230
  }
179
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
+ */
180
240
  deferred_reporter_base::~deferred_reporter_base ()
181
241
  {
182
242
  #if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
@@ -204,9 +264,45 @@ namespace micro_os_plus::micro_test_plus
204
264
  #endif
205
265
 
206
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
+ */
207
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
+ */
208
292
  test_reporter reporter;
209
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
+ */
210
306
  test_suite_base* current_test_suite;
211
307
 
212
308
  #if defined(__GNUC__)