@micro-os-plus/micro-test-plus 3.2.2 → 3.3.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.
- package/.cmake-format.yaml +11 -0
- package/CHANGELOG.md +417 -2
- package/CMakeLists.txt +33 -30
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/{xcdl.json → config/xcdl-build.json} +6 -6
- package/include/micro-os-plus/micro-test-plus/detail.h +1908 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
- package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
- package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +476 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
- package/include/micro-os-plus/micro-test-plus/math.h +217 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
- package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter-basic.h +289 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter-tap.h +281 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter.h +846 -0
- package/include/micro-os-plus/micro-test-plus/test-runner.h +281 -0
- package/include/micro-os-plus/micro-test-plus/test-suite.h +492 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
- package/include/micro-os-plus/micro-test-plus.h +172 -552
- package/meson.build +7 -5
- package/package.json +29 -34
- package/src/micro-test-plus.cpp +134 -37
- package/src/test-reporter-basic.cpp +466 -0
- package/src/test-reporter-tap.cpp +530 -0
- package/src/test-reporter.cpp +207 -240
- package/src/test-runner.cpp +135 -23
- package/src/test-suite.cpp +182 -10
- package/include/micro-os-plus/detail.h +0 -765
- package/include/micro-os-plus/inlines.h +0 -209
- package/include/micro-os-plus/literals.h +0 -512
- package/include/micro-os-plus/math.h +0 -204
- package/include/micro-os-plus/reflection.h +0 -139
- package/include/micro-os-plus/test-reporter-inlines.h +0 -230
- package/include/micro-os-plus/test-reporter.h +0 -356
- package/include/micro-os-plus/test-runner.h +0 -132
- package/include/micro-os-plus/test-suite.h +0 -306
- 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
|
-
#
|
|
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
|
-
#
|
|
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
|
|
|
@@ -46,6 +46,8 @@ _local_sources += [
|
|
|
46
46
|
'src/micro-test-plus.cpp',
|
|
47
47
|
'src/test-runner.cpp',
|
|
48
48
|
'src/test-reporter.cpp',
|
|
49
|
+
'src/test-reporter-basic.cpp',
|
|
50
|
+
'src/test-reporter-tap.cpp',
|
|
49
51
|
'src/test-suite.cpp',
|
|
50
52
|
]
|
|
51
53
|
|
package/package.json
CHANGED
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-os-plus/micro-test-plus",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
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
|
-
"
|
|
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.
|
|
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": "
|
|
61
|
+
"node": ">=20.0"
|
|
67
62
|
}
|
|
68
63
|
}
|
package/src/micro-test-plus.cpp
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
|
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()`,
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
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
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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)
|
|
@@ -186,7 +246,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
186
246
|
if (abort_ && !value_)
|
|
187
247
|
{
|
|
188
248
|
printf ("\n");
|
|
189
|
-
reporter
|
|
249
|
+
reporter->output ();
|
|
190
250
|
abort ();
|
|
191
251
|
}
|
|
192
252
|
}
|
|
@@ -204,9 +264,46 @@ 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;
|
|
208
|
-
test_reporter reporter;
|
|
209
279
|
|
|
280
|
+
/**
|
|
281
|
+
* @brief Global pointer to `test_reporter`.
|
|
282
|
+
*
|
|
283
|
+
* @details
|
|
284
|
+
* This global pointer to `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. The reporter is initialized in
|
|
291
|
+
* test_runner::initialize().
|
|
292
|
+
*/
|
|
293
|
+
test_reporter* reporter = nullptr;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @brief Global pointer references the currently active test suite.
|
|
297
|
+
*
|
|
298
|
+
* @details
|
|
299
|
+
* This global pointer references the currently active test suite within the
|
|
300
|
+
* µTest++ framework. It is used to track and update the state of the test
|
|
301
|
+
* suite during test execution, including recording test results and
|
|
302
|
+
* statistics. By maintaining a pointer to the current test suite, the
|
|
303
|
+
* framework ensures accurate association of test outcomes with their
|
|
304
|
+
* respective suites, supporting clear and organised reporting across all
|
|
305
|
+
* test cases and folders.
|
|
306
|
+
*/
|
|
210
307
|
test_suite_base* current_test_suite;
|
|
211
308
|
|
|
212
309
|
#if defined(__GNUC__)
|