@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,292 @@
|
|
|
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++ deferred reporter.
|
|
21
|
+
*
|
|
22
|
+
* @details
|
|
23
|
+
* This header provides the two deferred-reporter classes used by `expect()`
|
|
24
|
+
* and `assume()` to capture a test-expression result and format the outcome
|
|
25
|
+
* only when the reporter object is destroyed (i.e. at the semicolon
|
|
26
|
+
* following the expression statement).
|
|
27
|
+
*
|
|
28
|
+
* - `deferred_reporter_base` stores the boolean result, the source
|
|
29
|
+
* location, an optional user-supplied message (accumulated via
|
|
30
|
+
* `operator<<`), and a reference to the owning `subtest`. Its destructor
|
|
31
|
+
* calls the reporter to emit a pass or fail line.
|
|
32
|
+
* - `deferred_reporter<Expr_T>` derives from the base and additionally
|
|
33
|
+
* stores the original expression object so that the reporter can print
|
|
34
|
+
* the actual and expected values on failure.
|
|
35
|
+
*
|
|
36
|
+
* Both classes live in the `detail` namespace and are not part of the
|
|
37
|
+
* public API.
|
|
38
|
+
*
|
|
39
|
+
* This file is intended solely for internal use within the framework and
|
|
40
|
+
* should not be included directly by user code.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
#ifndef MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
|
|
44
|
+
#define MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
|
|
45
|
+
|
|
46
|
+
// ----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
#ifdef __cplusplus
|
|
49
|
+
|
|
50
|
+
// ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
#include <cstdio>
|
|
53
|
+
#include <string>
|
|
54
|
+
|
|
55
|
+
// ----------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
#if defined(__GNUC__)
|
|
58
|
+
#pragma GCC diagnostic push
|
|
59
|
+
#pragma GCC diagnostic ignored "-Wpadded"
|
|
60
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
61
|
+
#if defined(__clang__)
|
|
62
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
63
|
+
#endif
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
// ============================================================================
|
|
67
|
+
|
|
68
|
+
namespace micro_os_plus::micro_test_plus
|
|
69
|
+
{
|
|
70
|
+
class subtest;
|
|
71
|
+
|
|
72
|
+
// --------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @namespace micro_os_plus::micro_test_plus::detail
|
|
76
|
+
* @brief Internal implementation details for the µTest++ framework.
|
|
77
|
+
*
|
|
78
|
+
* @details
|
|
79
|
+
* The `detail` namespace encapsulates the internal mechanisms, helper
|
|
80
|
+
* structures, and implementation utilities employed by the µTest++ testing
|
|
81
|
+
* framework. These components do not form part of the public API and may be
|
|
82
|
+
* modified without prior notice.
|
|
83
|
+
*
|
|
84
|
+
* Within this namespace, one will find assertion handling, generic getter
|
|
85
|
+
* utilities, comparator structures for logical and relational operations,
|
|
86
|
+
* mechanisms for exception checking, and base classes for deferred reporting
|
|
87
|
+
* of test results.
|
|
88
|
+
*
|
|
89
|
+
* All definitions within `detail` are intended exclusively for internal use,
|
|
90
|
+
* ensuring a clear distinction between user-facing and internal components.
|
|
91
|
+
* This approach enhances maintainability, mitigates the risk of naming
|
|
92
|
+
* conflicts, and keeps the public API succinct.
|
|
93
|
+
*
|
|
94
|
+
* The relevant header files are organised within the `include/micro-os-plus`
|
|
95
|
+
* folder to maintain a structured and modular codebase.
|
|
96
|
+
*/
|
|
97
|
+
namespace detail
|
|
98
|
+
{
|
|
99
|
+
|
|
100
|
+
// ------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @brief Base class for a deferred reporter that collects messages into a
|
|
104
|
+
* string.
|
|
105
|
+
*
|
|
106
|
+
* @details
|
|
107
|
+
* The `deferred_reporter_base` class serves as the foundational component
|
|
108
|
+
* for deferred reporting within the framework. It is responsible for
|
|
109
|
+
* collecting expectation messages, typically passed via the
|
|
110
|
+
* `operator<<()`, into a string for later reporting.
|
|
111
|
+
*
|
|
112
|
+
* This class maintains the result value, abort status, and the source
|
|
113
|
+
* location associated with the report. It is intended exclusively for
|
|
114
|
+
* internal use and is implemented in the
|
|
115
|
+
* `include/micro-os-plus/micro-test-plus` folder to ensure a structured
|
|
116
|
+
* and modular codebase.
|
|
117
|
+
*
|
|
118
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
119
|
+
*/
|
|
120
|
+
class deferred_reporter_base
|
|
121
|
+
{
|
|
122
|
+
public:
|
|
123
|
+
/**
|
|
124
|
+
* @brief Constructs a deferred reporter base.
|
|
125
|
+
*
|
|
126
|
+
* @param value The result value associated with the report.
|
|
127
|
+
* @param location The source location relevant to the report.
|
|
128
|
+
* @param subtest The subtest that owns this deferred report.
|
|
129
|
+
*/
|
|
130
|
+
deferred_reporter_base (bool value,
|
|
131
|
+
const reflection::source_location& location,
|
|
132
|
+
subtest& subtest);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @brief Deleted copy constructor to prevent copying.
|
|
136
|
+
*/
|
|
137
|
+
deferred_reporter_base (const deferred_reporter_base&) = delete;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @brief Deleted move constructor to prevent moving.
|
|
141
|
+
*/
|
|
142
|
+
deferred_reporter_base (deferred_reporter_base&&) = delete;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @brief Deleted copy assignment operator to prevent copying.
|
|
146
|
+
*/
|
|
147
|
+
deferred_reporter_base&
|
|
148
|
+
operator= (const deferred_reporter_base&) = delete;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @brief Deleted move assignment operator to prevent moving.
|
|
152
|
+
*/
|
|
153
|
+
deferred_reporter_base&
|
|
154
|
+
operator= (deferred_reporter_base&&) = delete;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @brief Destructor for the deferred reporter base.
|
|
158
|
+
*/
|
|
159
|
+
~deferred_reporter_base ();
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @brief Appends a message to the reporter.
|
|
163
|
+
*
|
|
164
|
+
* @tparam T The type of the message to append.
|
|
165
|
+
*
|
|
166
|
+
* @param msg The message to append.
|
|
167
|
+
* @return Reference to the current reporter instance.
|
|
168
|
+
*/
|
|
169
|
+
template <class T>
|
|
170
|
+
requires type_traits::printable<T>
|
|
171
|
+
auto&
|
|
172
|
+
operator<< (const T& msg);
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @brief Retrieves the result value.
|
|
176
|
+
*
|
|
177
|
+
*
|
|
178
|
+
* @par Parameters
|
|
179
|
+
* None.
|
|
180
|
+
* @retval true The reported condition was met.
|
|
181
|
+
* @retval false The reported condition was not met.
|
|
182
|
+
*
|
|
183
|
+
* @details
|
|
184
|
+
* Returns the result value associated with the report.
|
|
185
|
+
*/
|
|
186
|
+
[[nodiscard]] bool
|
|
187
|
+
value () const
|
|
188
|
+
{
|
|
189
|
+
return value_;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
protected:
|
|
193
|
+
/**
|
|
194
|
+
* @brief Stores the result value of the report.
|
|
195
|
+
*/
|
|
196
|
+
bool value_{};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @brief Indicates whether the reporting should abort further
|
|
200
|
+
* processing.
|
|
201
|
+
*/
|
|
202
|
+
bool abort_ = false;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @brief Stores the source location associated with the report.
|
|
206
|
+
*/
|
|
207
|
+
const reflection::source_location location_{};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @brief String to collect the expectation message passed via
|
|
211
|
+
* `operator<<()`.
|
|
212
|
+
*/
|
|
213
|
+
std::string deferred_output_{};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @brief Reference to the test case invoking this report.
|
|
217
|
+
*/
|
|
218
|
+
subtest& subtest_;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// ------------------------------------------------------------------------
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @brief Deferred reporter class template for a specific expression.
|
|
225
|
+
*
|
|
226
|
+
* @tparam Expr_T The type of the expression being reported.
|
|
227
|
+
*
|
|
228
|
+
* @details
|
|
229
|
+
* The `deferred_reporter` class template extends `deferred_reporter_base`
|
|
230
|
+
* to provide deferred reporting functionality for a specific test
|
|
231
|
+
* expression within the framework.
|
|
232
|
+
*
|
|
233
|
+
* This class template is responsible for capturing the expression under
|
|
234
|
+
* evaluation, the abort status, and the source location. It is intended
|
|
235
|
+
* exclusively for internal use and is implemented in the
|
|
236
|
+
* `include/micro-os-plus/micro-test-plus` folder to ensure a structured
|
|
237
|
+
* and modular codebase.
|
|
238
|
+
*
|
|
239
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
240
|
+
*/
|
|
241
|
+
template <class Expr_T>
|
|
242
|
+
class deferred_reporter : public deferred_reporter_base
|
|
243
|
+
{
|
|
244
|
+
public:
|
|
245
|
+
/**
|
|
246
|
+
* @brief Constructs a deferred reporter for a specific expression.
|
|
247
|
+
*
|
|
248
|
+
* @param expr The expression under evaluation.
|
|
249
|
+
* @param abort Indicates whether reporting should abort further
|
|
250
|
+
* processing.
|
|
251
|
+
* @param location The source location relevant to the report.
|
|
252
|
+
* @param subtest The subtest that owns this deferred report.
|
|
253
|
+
*
|
|
254
|
+
* @details
|
|
255
|
+
* Initialises the reporter with the given expression, abort status, and
|
|
256
|
+
* source location.
|
|
257
|
+
*/
|
|
258
|
+
deferred_reporter (const Expr_T& expr, bool abort,
|
|
259
|
+
const reflection::source_location& location,
|
|
260
|
+
subtest& subtest);
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @brief Destructor for the deferred reporter.
|
|
264
|
+
*/
|
|
265
|
+
~deferred_reporter ();
|
|
266
|
+
|
|
267
|
+
protected:
|
|
268
|
+
/**
|
|
269
|
+
* @brief Stores the expression under evaluation.
|
|
270
|
+
*/
|
|
271
|
+
const Expr_T expr_{};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// ------------------------------------------------------------------------
|
|
275
|
+
} // namespace detail
|
|
276
|
+
|
|
277
|
+
// --------------------------------------------------------------------------
|
|
278
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
279
|
+
|
|
280
|
+
#if defined(__GNUC__)
|
|
281
|
+
#pragma GCC diagnostic pop
|
|
282
|
+
#endif
|
|
283
|
+
|
|
284
|
+
// ----------------------------------------------------------------------------
|
|
285
|
+
|
|
286
|
+
#endif // __cplusplus
|
|
287
|
+
|
|
288
|
+
// ----------------------------------------------------------------------------
|
|
289
|
+
|
|
290
|
+
#endif // MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
|
|
291
|
+
|
|
292
|
+
// ----------------------------------------------------------------------------
|