@micro-os-plus/micro-test-plus 3.3.0 → 4.0.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/CHANGELOG.md +339 -2
- package/CMakeLists.txt +79 -23
- package/README.md +1 -1
- package/config/xcdl-build.json +11 -4
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +292 -0
- package/include/micro-os-plus/micro-test-plus/detail.h +462 -1076
- package/include/micro-os-plus/micro-test-plus/exceptions.h +126 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +10 -7
- package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +49 -22
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +67 -4
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +3 -6
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +21 -15
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +35 -17
- package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → reporter-inlines.h} +176 -106
- package/include/micro-os-plus/micro-test-plus/inlines/{test-suite-inlines.h → runner-inlines.h} +41 -43
- package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +369 -0
- package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +4 -3
- package/include/micro-os-plus/micro-test-plus/math.h +9 -6
- package/include/micro-os-plus/micro-test-plus/operators.h +38 -44
- package/include/micro-os-plus/micro-test-plus/reflection.h +15 -4
- package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +72 -72
- package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +69 -69
- package/include/micro-os-plus/micro-test-plus/{test-reporter.h → reporter.h} +296 -200
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +264 -0
- package/include/micro-os-plus/micro-test-plus/runner.h +453 -0
- package/include/micro-os-plus/micro-test-plus/test.h +1069 -0
- package/include/micro-os-plus/micro-test-plus/timings.h +366 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +239 -545
- package/include/micro-os-plus/micro-test-plus/utility.h +135 -0
- package/include/micro-os-plus/micro-test-plus.h +25 -228
- package/meson.build +10 -6
- package/package.json +1 -1
- package/src/deferred-reporter.cpp +118 -0
- package/src/reflection.cpp +95 -0
- package/src/reporter-human.cpp +822 -0
- package/src/reporter-tap.cpp +782 -0
- package/src/reporter.cpp +676 -0
- package/src/runner-totals.cpp +95 -0
- package/src/runner.cpp +563 -0
- package/src/test.cpp +496 -0
- package/src/timings.cpp +209 -0
- package/src/utility.cpp +163 -0
- package/.cmake-format.yaml +0 -11
- package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
- package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
- package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
- package/src/micro-test-plus.cpp +0 -316
- package/src/test-reporter-basic.cpp +0 -466
- package/src/test-reporter-tap.cpp +0 -530
- package/src/test-reporter.cpp +0 -399
- package/src/test-runner.cpp +0 -311
- package/src/test-suite.cpp +0 -304
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*
|
|
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.
|
|
4
|
+
*
|
|
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
|
+
*
|
|
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
|
+
*
|
|
11
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
13
|
+
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @file
|
|
20
|
+
* @brief C++ header file with declarations for the µTest++ utility helpers.
|
|
21
|
+
*
|
|
22
|
+
* @details
|
|
23
|
+
* This header provides declarations for the utility helper functions used
|
|
24
|
+
* within the µTest++ framework. It defines interfaces for string operations
|
|
25
|
+
* including file-name extraction, pattern matching, and string splitting.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#ifndef MICRO_TEST_PLUS_UTILITY_H_
|
|
29
|
+
#define MICRO_TEST_PLUS_UTILITY_H_
|
|
30
|
+
|
|
31
|
+
// ----------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
#ifdef __cplusplus
|
|
34
|
+
|
|
35
|
+
// ----------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
38
|
+
#include <micro-os-plus/config.h>
|
|
39
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
40
|
+
|
|
41
|
+
#include <string_view>
|
|
42
|
+
#include <vector>
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#if defined(__GNUC__)
|
|
47
|
+
#pragma GCC diagnostic push
|
|
48
|
+
#if defined(__clang__)
|
|
49
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
50
|
+
#endif
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
|
|
55
|
+
namespace micro_os_plus::micro_test_plus
|
|
56
|
+
{
|
|
57
|
+
// --------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @namespace micro_os_plus::micro_test_plus::utility
|
|
61
|
+
* @brief Utility functions for the µTest++ testing framework.
|
|
62
|
+
*
|
|
63
|
+
* @details
|
|
64
|
+
* The `micro_os_plus::micro_test_plus::utility` namespace provides a suite
|
|
65
|
+
* of helper functions designed to support advanced string operations and
|
|
66
|
+
* other common tasks within the µTest++ framework.
|
|
67
|
+
*
|
|
68
|
+
* These utilities include functions for pattern matching—such as verifying
|
|
69
|
+
* whether a string matches a specified pattern—and for splitting strings
|
|
70
|
+
* into sub-strings based on delimiters. The implementations are efficient
|
|
71
|
+
* and suitable for both embedded and general C++ projects.
|
|
72
|
+
*
|
|
73
|
+
* By encapsulating these helper functions within a dedicated namespace, the
|
|
74
|
+
* framework maintains clear code organisation and minimises naming
|
|
75
|
+
* conflicts.
|
|
76
|
+
*/
|
|
77
|
+
namespace utility
|
|
78
|
+
{
|
|
79
|
+
/**
|
|
80
|
+
* @ingroup micro-test-plus-utility-functions
|
|
81
|
+
* @brief Extracts the file name component from a full path.
|
|
82
|
+
*
|
|
83
|
+
* @param [in] path A null-terminated file path string.
|
|
84
|
+
* @return A pointer to the first character of the file name within
|
|
85
|
+
* `path`, or `path` itself if no directory separator is found.
|
|
86
|
+
*/
|
|
87
|
+
[[nodiscard]] const char*
|
|
88
|
+
extract_file_name (const char* path) noexcept;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @ingroup micro-test-plus-utility-functions
|
|
92
|
+
* @brief Check if a string matches a pattern.
|
|
93
|
+
*
|
|
94
|
+
* @param [in] input The string view to be checked.
|
|
95
|
+
* @param [in] pattern The string view containing the pattern to match.
|
|
96
|
+
* @return `true` if the input string matches the pattern; otherwise,
|
|
97
|
+
* `false`.
|
|
98
|
+
*/
|
|
99
|
+
[[nodiscard]] bool
|
|
100
|
+
is_match (std::string_view input, std::string_view pattern);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @ingroup micro-test-plus-utility-functions
|
|
104
|
+
* @brief Split a string into a vector of sub-strings.
|
|
105
|
+
*
|
|
106
|
+
* @tparam T Type of the input string.
|
|
107
|
+
* @tparam Delim_T Type of the delimiter.
|
|
108
|
+
*
|
|
109
|
+
* @param [in] input Input string to split.
|
|
110
|
+
* @param [in] delim Delimiter string.
|
|
111
|
+
* @return A vector containing the resulting sub-strings.
|
|
112
|
+
*/
|
|
113
|
+
template <class T, class Delim_T>
|
|
114
|
+
[[nodiscard]] auto
|
|
115
|
+
split (T input, Delim_T delim) -> std::vector<T>;
|
|
116
|
+
|
|
117
|
+
// ------------------------------------------------------------------------
|
|
118
|
+
} // namespace utility
|
|
119
|
+
|
|
120
|
+
// --------------------------------------------------------------------------
|
|
121
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
122
|
+
|
|
123
|
+
#if defined(__GNUC__)
|
|
124
|
+
#pragma GCC diagnostic pop
|
|
125
|
+
#endif
|
|
126
|
+
|
|
127
|
+
// ----------------------------------------------------------------------------
|
|
128
|
+
|
|
129
|
+
#endif // __cplusplus
|
|
130
|
+
|
|
131
|
+
// ----------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
#endif // MICRO_TEST_PLUS_UTILITY_H_
|
|
134
|
+
|
|
135
|
+
// ----------------------------------------------------------------------------
|
|
@@ -71,26 +71,22 @@
|
|
|
71
71
|
#include "micro-test-plus/math.h"
|
|
72
72
|
#include "micro-test-plus/literals.h"
|
|
73
73
|
#include "micro-test-plus/function-comparators.h"
|
|
74
|
+
#include "micro-test-plus/exceptions.h"
|
|
74
75
|
#include "micro-test-plus/operators.h"
|
|
75
76
|
|
|
76
|
-
#include "micro-test-plus/
|
|
77
|
-
#include "micro-test-plus/test
|
|
78
|
-
#include "micro-test-plus/test-reporter.h"
|
|
79
|
-
#include "micro-test-plus/test-reporter-basic.h"
|
|
80
|
-
#include "micro-test-plus/test-reporter-tap.h"
|
|
77
|
+
#include "micro-test-plus/deferred-reporter.h"
|
|
78
|
+
#include "micro-test-plus/test.h"
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
#include "micro-test-plus/runner.h"
|
|
81
|
+
#include "micro-test-plus/runner-totals.h"
|
|
82
|
+
|
|
83
|
+
#include "micro-test-plus/reporter.h"
|
|
84
|
+
#include "micro-test-plus/reporter-human.h"
|
|
85
|
+
#include "micro-test-plus/reporter-tap.h"
|
|
83
86
|
|
|
84
|
-
#
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
88
|
-
#if defined(__clang__)
|
|
89
|
-
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
90
|
-
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
91
|
-
#pragma clang diagnostic ignored "-Wctad-maybe-unsupported"
|
|
92
|
-
#endif
|
|
93
|
-
#endif
|
|
87
|
+
#include "micro-test-plus/utility.h"
|
|
88
|
+
|
|
89
|
+
// ----------------------------------------------------------------------------
|
|
94
90
|
|
|
95
91
|
/**
|
|
96
92
|
* @namespace micro_os_plus::micro_test_plus
|
|
@@ -116,229 +112,30 @@
|
|
|
116
112
|
* folder, ensuring a clear separation from user code and facilitating
|
|
117
113
|
* straightforward integration with the wider µOS++ ecosystem.
|
|
118
114
|
*/
|
|
119
|
-
namespace micro_os_plus::micro_test_plus
|
|
120
|
-
{
|
|
121
|
-
// --------------------------------------------------------------------------
|
|
122
|
-
|
|
123
|
-
extern test_runner runner;
|
|
124
|
-
extern test_reporter* reporter;
|
|
125
|
-
extern test_suite_base* current_test_suite;
|
|
126
|
-
|
|
127
|
-
// --------------------------------------------------------------------------
|
|
128
|
-
// Public API.
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @ingroup micro-test-plus-inits
|
|
132
|
-
* @brief Initialise the µTest++ framework.
|
|
133
|
-
*
|
|
134
|
-
* @param [in] argc The number of command-line arguments.
|
|
135
|
-
* @param [in] argv Array of pointers to null-terminated argument strings.
|
|
136
|
-
* @param [in] name The name of the default test suite. Defaults to `"Main"`
|
|
137
|
-
* if not specified.
|
|
138
|
-
* @par Returns
|
|
139
|
-
* Nothing.
|
|
140
|
-
*/
|
|
141
|
-
void
|
|
142
|
-
initialize (int argc, char* argv[], const char* name = "Main");
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @ingroup micro-test-plus-inits
|
|
146
|
-
* @brief Complete the test run and return the exit code.
|
|
147
|
-
*
|
|
148
|
-
* @par Parameters
|
|
149
|
-
* None.
|
|
150
|
-
* @return 0 if all tests were successful, 1 if any test failed.
|
|
151
|
-
*/
|
|
152
|
-
[[nodiscard]] int
|
|
153
|
-
exit_code (void);
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @ingroup micro-test-plus-test-case
|
|
157
|
-
* @brief Define and execute a test case.
|
|
158
|
-
*
|
|
159
|
-
* @tparam Callable_T The type of the callable object to be executed as the
|
|
160
|
-
* test case.
|
|
161
|
-
* @tparam Args_T The types of the arguments to be passed to the callable.
|
|
162
|
-
* @param [in] name The test case name or description, used in test reports.
|
|
163
|
-
* @param [in] callable A generic callable object, usually a lambda, invoked
|
|
164
|
-
* to perform the test.
|
|
165
|
-
* @param [in] arguments A possibly empty list of arguments to be passed to
|
|
166
|
-
* the callable.
|
|
167
|
-
* @par Returns
|
|
168
|
-
* Nothing.
|
|
169
|
-
*/
|
|
170
|
-
template <typename Callable_T, typename... Args_T>
|
|
171
|
-
void
|
|
172
|
-
test_case (const char* name, Callable_T&& callable, Args_T&&... arguments);
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @ingroup micro-test-plus-expectations
|
|
176
|
-
* @brief Evaluate a generic condition and report the results.
|
|
177
|
-
*
|
|
178
|
-
* @tparam Expr_T The type of the custom expression.
|
|
179
|
-
*
|
|
180
|
-
* @par SFINAE
|
|
181
|
-
* Enabled only if `Expr_T` is derived from `detail::op` or
|
|
182
|
-
* is convertible to `bool`.
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
* @param [in] expr Logical expression to evaluate.
|
|
186
|
-
* @param [in] sl Optional source location, defaulting to the current line.
|
|
187
|
-
* @return An output stream to write optional messages.
|
|
188
|
-
*/
|
|
189
|
-
template <class Expr_T, type_traits::requires_t<
|
|
190
|
-
type_traits::is_op_v<Expr_T>
|
|
191
|
-
or type_traits::is_convertible_v<Expr_T, bool>>
|
|
192
|
-
= 0>
|
|
193
|
-
constexpr auto
|
|
194
|
-
expect (const Expr_T& expr, const reflection::source_location& sl
|
|
195
|
-
= reflection::source_location::current ());
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @ingroup micro-test-plus-assumptions
|
|
199
|
-
* @brief Check a condition and, if false, abort test execution.
|
|
200
|
-
*
|
|
201
|
-
* @tparam Expr_T The type of the custom expression.
|
|
202
|
-
*
|
|
203
|
-
* @par SFINAE
|
|
204
|
-
* Enabled only if `Expr_T` is derived from `detail::op` or
|
|
205
|
-
* is convertible to `bool`.
|
|
206
|
-
*
|
|
207
|
-
* @param [in] expr Logical expression to evaluate.
|
|
208
|
-
* @param [in] sl Optional source location, defaulting to the current line.
|
|
209
|
-
* @return An output stream to write optional messages.
|
|
210
|
-
*/
|
|
211
|
-
template <class Expr_T, type_traits::requires_t<
|
|
212
|
-
type_traits::is_op_v<Expr_T>
|
|
213
|
-
or type_traits::is_convertible_v<Expr_T, bool>>
|
|
214
|
-
= 0>
|
|
215
|
-
constexpr auto
|
|
216
|
-
assume (const Expr_T& expr, const reflection::source_location& sl
|
|
217
|
-
= reflection::source_location::current ());
|
|
218
|
-
|
|
219
|
-
// --------------------------------------------------------------------------
|
|
220
|
-
|
|
221
|
-
#if defined(__cpp_exceptions)
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* @ingroup micro-test-plus-exceptions
|
|
225
|
-
* @brief Check if a callable throws a specific exception.
|
|
226
|
-
*
|
|
227
|
-
* @tparam Exception_T The type of the exception expected to be thrown.
|
|
228
|
-
* @tparam Callable_T The type of the callable object to be invoked.
|
|
229
|
-
* @param [in] func The callable object to check for exception throwing
|
|
230
|
-
* behaviour.
|
|
231
|
-
* @return An output stream to write optional messages.
|
|
232
|
-
*/
|
|
233
|
-
template <class Exception_T, class Callable_T>
|
|
234
|
-
[[nodiscard]] constexpr auto
|
|
235
|
-
throws (const Callable_T& func);
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @ingroup micro-test-plus-exceptions
|
|
239
|
-
* @brief Check if a callable throws an exception (any exception).
|
|
240
|
-
*
|
|
241
|
-
* @tparam Callable_T The type of the callable object to be invoked.
|
|
242
|
-
* @param [in] func The callable object to check for exception throwing
|
|
243
|
-
* behaviour.
|
|
244
|
-
* @return An output stream to write optional messages.
|
|
245
|
-
*/
|
|
246
|
-
template <class Callable_T>
|
|
247
|
-
[[nodiscard]] constexpr auto
|
|
248
|
-
throws (const Callable_T& func);
|
|
249
115
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
* @brief Check if a callable does not throw an exception.
|
|
253
|
-
*
|
|
254
|
-
* @tparam Callable_T The type of the callable object to be invoked.
|
|
255
|
-
* @param [in] func The callable object to check for exception safety.
|
|
256
|
-
* @return An output stream to write optional messages.
|
|
257
|
-
*/
|
|
258
|
-
template <class Callable_T>
|
|
259
|
-
[[nodiscard]] constexpr auto
|
|
260
|
-
nothrow (const Callable_T& func);
|
|
116
|
+
// ============================================================================
|
|
117
|
+
// Templates & constexpr implementations.
|
|
261
118
|
|
|
262
|
-
#
|
|
263
|
-
|
|
264
|
-
// --------------------------------------------------------------------------
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @namespace micro_os_plus::micro_test_plus::utility
|
|
268
|
-
* @brief Utility functions for the µTest++ testing framework.
|
|
269
|
-
*
|
|
270
|
-
* @details
|
|
271
|
-
* The `micro_os_plus::micro_test_plus::utility` namespace provides a suite
|
|
272
|
-
* of helper functions designed to support advanced string operations and
|
|
273
|
-
* other common tasks within the µTest++ framework.
|
|
274
|
-
*
|
|
275
|
-
* These utilities include functions for pattern matching—such as verifying
|
|
276
|
-
* whether a string matches a specified pattern—and for splitting strings
|
|
277
|
-
* into sub-strings based on delimiters. The implementations are efficient
|
|
278
|
-
* and suitable for both embedded and general C++ projects.
|
|
279
|
-
*
|
|
280
|
-
* By encapsulating these helper functions within a dedicated namespace, the
|
|
281
|
-
* framework maintains clear code organisation and minimises naming
|
|
282
|
-
* conflicts.
|
|
283
|
-
*/
|
|
284
|
-
namespace utility
|
|
285
|
-
{
|
|
286
|
-
/**
|
|
287
|
-
* @ingroup micro-test-plus-utility-functions
|
|
288
|
-
* @brief Check if a string matches a pattern.
|
|
289
|
-
*
|
|
290
|
-
* @param [in] input The string view to be checked.
|
|
291
|
-
* @param [in] pattern The string view containing the pattern to match.
|
|
292
|
-
* @return `true` if the input string matches the pattern; otherwise,
|
|
293
|
-
* `false`.
|
|
294
|
-
*/
|
|
295
|
-
[[nodiscard]] bool
|
|
296
|
-
is_match (std::string_view input, std::string_view pattern);
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* @ingroup micro-test-plus-utility-functions
|
|
300
|
-
* @brief Split a string into a vector of sub-strings.
|
|
301
|
-
*
|
|
302
|
-
* @tparam T Type of the input string.
|
|
303
|
-
* @tparam Delim_T Type of the delimiter.
|
|
304
|
-
*
|
|
305
|
-
* @param [in] input Input string to split.
|
|
306
|
-
* @param [in] delim Delimiter string.
|
|
307
|
-
* @return A vector containing the resulting sub-strings.
|
|
308
|
-
*/
|
|
309
|
-
template <class T, class Delim_T>
|
|
310
|
-
[[nodiscard]] auto
|
|
311
|
-
split (T input, Delim_T delim) -> std::vector<T>;
|
|
312
|
-
|
|
313
|
-
// ------------------------------------------------------------------------
|
|
314
|
-
} // namespace utility
|
|
315
|
-
|
|
316
|
-
// --------------------------------------------------------------------------
|
|
317
|
-
} // namespace micro_os_plus::micro_test_plus
|
|
318
|
-
|
|
319
|
-
#if defined(__GNUC__)
|
|
320
|
-
#pragma GCC diagnostic pop
|
|
321
|
-
#endif
|
|
322
|
-
|
|
323
|
-
// ----------------------------------------------------------------------------
|
|
324
|
-
|
|
325
|
-
#endif // __cplusplus
|
|
326
|
-
|
|
327
|
-
// ===== Inlines & templates implementations
|
|
328
|
-
// ====================================
|
|
119
|
+
#include <micro-os-plus/diag/trace.h>
|
|
329
120
|
|
|
330
121
|
// All inlines are included **after** all declarations.
|
|
331
|
-
#include "micro-test-plus/inlines/details-inlines.h"
|
|
332
122
|
#include "micro-test-plus/inlines/literals-inlines.h"
|
|
333
123
|
#include "micro-test-plus/inlines/math-inlines.h"
|
|
334
124
|
|
|
335
125
|
#include "micro-test-plus/inlines/reflection-inlines.h"
|
|
336
|
-
|
|
126
|
+
|
|
127
|
+
#include "micro-test-plus/inlines/deferred-reporter-inlines.h"
|
|
128
|
+
#include "micro-test-plus/inlines/reporter-inlines.h"
|
|
337
129
|
|
|
338
130
|
#include "micro-test-plus/inlines/function-comparators-inlines.h"
|
|
339
|
-
#include "micro-test-plus/inlines/
|
|
131
|
+
#include "micro-test-plus/inlines/runner-inlines.h"
|
|
132
|
+
#include "micro-test-plus/inlines/test-inlines.h"
|
|
340
133
|
|
|
341
|
-
#include "micro-test-plus/inlines/
|
|
134
|
+
#include "micro-test-plus/inlines/utility-inlines.h"
|
|
135
|
+
|
|
136
|
+
// ----------------------------------------------------------------------------
|
|
137
|
+
|
|
138
|
+
#endif // __cplusplus
|
|
342
139
|
|
|
343
140
|
// ----------------------------------------------------------------------------
|
|
344
141
|
|
package/meson.build
CHANGED
|
@@ -43,12 +43,16 @@ _local_include_directories += [
|
|
|
43
43
|
]
|
|
44
44
|
|
|
45
45
|
_local_sources += [
|
|
46
|
-
'src/
|
|
47
|
-
'src/
|
|
48
|
-
'src/
|
|
49
|
-
'src/
|
|
50
|
-
'src/
|
|
51
|
-
'src/
|
|
46
|
+
'src/runner.cpp',
|
|
47
|
+
'src/runner-totals.cpp',
|
|
48
|
+
'src/deferred-reporter.cpp',
|
|
49
|
+
'src/reporter.cpp',
|
|
50
|
+
'src/reporter-human.cpp',
|
|
51
|
+
'src/reporter-tap.cpp',
|
|
52
|
+
'src/test.cpp',
|
|
53
|
+
'src/timings.cpp',
|
|
54
|
+
'src/reflection.cpp',
|
|
55
|
+
'src/utility.cpp',
|
|
52
56
|
]
|
|
53
57
|
|
|
54
58
|
# https://mesonbuild.com/Reference-manual_functions.html#declare_dependency
|
package/package.json
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
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.
|
|
4
|
+
*
|
|
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
|
+
*
|
|
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
|
+
*
|
|
11
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
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++ deferred
|
|
21
|
+
* reporter methods.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This source file contains the implementation of the
|
|
25
|
+
* `detail::deferred_reporter_base` class, which supports deferred
|
|
26
|
+
* reporting of test expression results. The constructor captures the
|
|
27
|
+
* result value, source location, and subtest reference; the destructor
|
|
28
|
+
* updates the subtest counters and optionally aborts execution on
|
|
29
|
+
* critical failures.
|
|
30
|
+
*
|
|
31
|
+
* All definitions reside within the
|
|
32
|
+
* `micro_os_plus::micro_test_plus::detail` namespace.
|
|
33
|
+
*
|
|
34
|
+
* This file must be included when building the µTest++ library.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
40
|
+
#include <micro-os-plus/config.h>
|
|
41
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
42
|
+
|
|
43
|
+
#include <micro-os-plus/micro-test-plus.h>
|
|
44
|
+
#include <micro-os-plus/diag/trace.h>
|
|
45
|
+
|
|
46
|
+
// ----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
#if defined(__GNUC__)
|
|
49
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
50
|
+
#if defined(__clang__)
|
|
51
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
52
|
+
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
|
53
|
+
#pragma clang diagnostic ignored "-Wglobal-constructors"
|
|
54
|
+
#endif
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
// ============================================================================
|
|
58
|
+
|
|
59
|
+
namespace micro_os_plus::micro_test_plus
|
|
60
|
+
{
|
|
61
|
+
// --------------------------------------------------------------------------
|
|
62
|
+
namespace detail
|
|
63
|
+
{
|
|
64
|
+
/**
|
|
65
|
+
* @details
|
|
66
|
+
* Stores the evaluated Boolean @p value, the @p location identifying
|
|
67
|
+
* the source line of the assertion, and a reference to the owning
|
|
68
|
+
* @p subtest. The subtest's check index counter is incremented
|
|
69
|
+
* immediately so that the first check is reported as check #1.
|
|
70
|
+
*/
|
|
71
|
+
deferred_reporter_base::deferred_reporter_base (
|
|
72
|
+
bool value, const reflection::source_location& location,
|
|
73
|
+
subtest& subtest)
|
|
74
|
+
: value_{ value }, location_{ location }, subtest_{ subtest }
|
|
75
|
+
{
|
|
76
|
+
// The index starts at 0, must be incremented before the first check is
|
|
77
|
+
// reported, to ensure that the first check is reported as check #1.
|
|
78
|
+
subtest_.increment_subtest_index ();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @details
|
|
83
|
+
* The destructor ensures that if an abort condition is set and the test
|
|
84
|
+
* expression has failed, the test output is flushed and the process is
|
|
85
|
+
* terminated. This mechanism guarantees immediate feedback and halts
|
|
86
|
+
* further execution upon critical test failures, aiding in rapid
|
|
87
|
+
* identification and resolution of issues during test runs.
|
|
88
|
+
*/
|
|
89
|
+
deferred_reporter_base::~deferred_reporter_base ()
|
|
90
|
+
{
|
|
91
|
+
#if defined(MICRO_OS_PLUS_TRACE) \
|
|
92
|
+
&& defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
|
|
93
|
+
trace::printf ("%s\n", __PRETTY_FUNCTION__);
|
|
94
|
+
#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
|
|
95
|
+
|
|
96
|
+
if (value_) [[likely]]
|
|
97
|
+
{
|
|
98
|
+
subtest_.totals ().increment_successful_checks ();
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
{
|
|
102
|
+
subtest_.totals ().increment_failed_checks ();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (abort_ && !value_) [[unlikely]]
|
|
106
|
+
{
|
|
107
|
+
subtest_.reporter ().write_buffer_to_stdout ();
|
|
108
|
+
subtest_.reporter ().flush ();
|
|
109
|
+
subtest_.abort (location_);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} // namespace detail
|
|
114
|
+
|
|
115
|
+
// ==========================================================================
|
|
116
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
117
|
+
|
|
118
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
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.
|
|
4
|
+
*
|
|
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
|
+
*
|
|
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
|
+
*
|
|
11
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
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 implementation of
|
|
24
|
+
* `reflection::short_name()`, which extracts the base file name from a
|
|
25
|
+
* fully qualified path by returning the portion after the last `/`
|
|
26
|
+
* separator, or the original string if no separator is present.
|
|
27
|
+
*
|
|
28
|
+
* All definitions reside within the
|
|
29
|
+
* `micro_os_plus::micro_test_plus::reflection` namespace.
|
|
30
|
+
*
|
|
31
|
+
* This file must be included when building the µTest++ library.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// ----------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
37
|
+
#include <micro-os-plus/config.h>
|
|
38
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
39
|
+
|
|
40
|
+
#include <micro-os-plus/micro-test-plus.h>
|
|
41
|
+
|
|
42
|
+
// ----------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
#if defined(__GNUC__)
|
|
45
|
+
#if defined(__clang__)
|
|
46
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
47
|
+
#endif
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
namespace micro_os_plus::micro_test_plus
|
|
53
|
+
{
|
|
54
|
+
// --------------------------------------------------------------------------
|
|
55
|
+
// Public API.
|
|
56
|
+
|
|
57
|
+
// --------------------------------------------------------------------------
|
|
58
|
+
// Too small to deserve a separate source file.
|
|
59
|
+
namespace reflection
|
|
60
|
+
{
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @details
|
|
64
|
+
* This function extracts the short name from a given file path by locating
|
|
65
|
+
* the final folder separator ('/'). If a separator is found, it returns a
|
|
66
|
+
* pointer to the character immediately following it, effectively providing
|
|
67
|
+
* the file or folder name. If no separator is present, the original input
|
|
68
|
+
* string is returned. This utility is useful for reporting concise file or
|
|
69
|
+
* folder names in test output.
|
|
70
|
+
*/
|
|
71
|
+
const char*
|
|
72
|
+
short_name (const char* name) noexcept
|
|
73
|
+
{
|
|
74
|
+
#if defined(__GNUC__)
|
|
75
|
+
#pragma GCC diagnostic push
|
|
76
|
+
#if defined(__clang__)
|
|
77
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
78
|
+
#endif
|
|
79
|
+
#endif
|
|
80
|
+
const char* p = strrchr (name, '/');
|
|
81
|
+
if (p != nullptr)
|
|
82
|
+
return p + 1;
|
|
83
|
+
else
|
|
84
|
+
return name;
|
|
85
|
+
#if defined(__GNUC__)
|
|
86
|
+
#pragma GCC diagnostic pop
|
|
87
|
+
#endif
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
} // namespace reflection
|
|
91
|
+
|
|
92
|
+
// ==========================================================================
|
|
93
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
94
|
+
|
|
95
|
+
// ----------------------------------------------------------------------------
|