@micro-os-plus/micro-test-plus 3.3.1 → 4.1.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 +412 -2
- package/CMakeLists.txt +134 -28
- package/README.md +3 -2
- package/config/xcdl-build.json +11 -4
- package/include/micro-os-plus/micro-test-plus/README.md +6 -0
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +267 -0
- package/include/micro-os-plus/micro-test-plus/detail.h +272 -1425
- package/include/micro-os-plus/micro-test-plus/exceptions.h +125 -0
- package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +15 -7
- package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +66 -44
- package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
- package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
- package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → expression-formatter-inlines.h} +232 -198
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +24 -20
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +50 -31
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +25 -19
- package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +39 -21
- package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +205 -0
- package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +151 -0
- package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +555 -0
- package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
- package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +231 -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 +12 -17
- package/include/micro-os-plus/micro-test-plus/math.h +14 -6
- package/include/micro-os-plus/micro-test-plus/operators.h +53 -209
- package/include/micro-os-plus/micro-test-plus/reflection.h +8 -4
- package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +80 -74
- package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +77 -71
- package/include/micro-os-plus/micro-test-plus/reporter.h +619 -0
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +250 -0
- package/include/micro-os-plus/micro-test-plus/runner.h +472 -0
- package/include/micro-os-plus/micro-test-plus/test.h +1013 -0
- package/include/micro-os-plus/micro-test-plus/timings.h +363 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +223 -577
- package/include/micro-os-plus/micro-test-plus/utility.h +136 -0
- package/include/micro-os-plus/micro-test-plus.h +42 -236
- package/meson.build +11 -6
- package/package.json +11 -3
- package/src/deferred-reporter.cpp +137 -0
- package/src/expression-formatter.cpp +289 -0
- package/src/reflection.cpp +97 -0
- package/src/reporter-human.cpp +816 -0
- package/src/reporter-tap.cpp +772 -0
- package/src/reporter.cpp +481 -0
- package/src/runner-totals.cpp +98 -0
- package/src/runner.cpp +669 -0
- package/src/test.cpp +503 -0
- package/src/timings.cpp +210 -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/inlines/test-suite-inlines.h +0 -115
- package/include/micro-os-plus/micro-test-plus/test-reporter.h +0 -846
- 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,267 @@
|
|
|
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
|
+
#include "type-traits.h"
|
|
56
|
+
#include "reflection.h"
|
|
57
|
+
#include "expression-formatter.h"
|
|
58
|
+
|
|
59
|
+
// ----------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
#if defined(__GNUC__)
|
|
62
|
+
#pragma GCC diagnostic push
|
|
63
|
+
#pragma GCC diagnostic ignored "-Wpadded"
|
|
64
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
65
|
+
#if defined(__clang__)
|
|
66
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
67
|
+
#endif
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
namespace micro_os_plus::micro_test_plus
|
|
73
|
+
{
|
|
74
|
+
class subtest;
|
|
75
|
+
|
|
76
|
+
// --------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
namespace detail
|
|
79
|
+
{
|
|
80
|
+
// ========================================================================
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @brief Base class for a deferred reporter that collects messages into a
|
|
84
|
+
* string.
|
|
85
|
+
*
|
|
86
|
+
* @details
|
|
87
|
+
* The `deferred_reporter_base` class serves as the foundational component
|
|
88
|
+
* for deferred reporting within the framework. It is responsible for
|
|
89
|
+
* collecting expectation messages, typically passed via the
|
|
90
|
+
* `operator<<()`, into a string for later reporting.
|
|
91
|
+
*
|
|
92
|
+
* This class maintains the result value, abort status, and the source
|
|
93
|
+
* location associated with the report. It is intended exclusively for
|
|
94
|
+
* internal use and is implemented in the
|
|
95
|
+
* `include/micro-os-plus/micro-test-plus` folder to ensure a structured
|
|
96
|
+
* and modular codebase.
|
|
97
|
+
*
|
|
98
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
99
|
+
*/
|
|
100
|
+
class deferred_reporter_base
|
|
101
|
+
{
|
|
102
|
+
public:
|
|
103
|
+
/**
|
|
104
|
+
* @brief Constructs a deferred reporter base.
|
|
105
|
+
*
|
|
106
|
+
* @param value The result value associated with the report.
|
|
107
|
+
* @param location The source location relevant to the report.
|
|
108
|
+
* @param subtest The subtest that owns this deferred report.
|
|
109
|
+
*/
|
|
110
|
+
deferred_reporter_base (bool value,
|
|
111
|
+
const reflection::source_location& location,
|
|
112
|
+
subtest& subtest);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @brief Deleted copy constructor to prevent copying.
|
|
116
|
+
*/
|
|
117
|
+
deferred_reporter_base (const deferred_reporter_base&) = delete;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @brief Deleted move constructor to prevent moving.
|
|
121
|
+
*/
|
|
122
|
+
deferred_reporter_base (deferred_reporter_base&&) = delete;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @brief Deleted copy assignment operator to prevent copying.
|
|
126
|
+
*/
|
|
127
|
+
deferred_reporter_base&
|
|
128
|
+
operator= (const deferred_reporter_base&)
|
|
129
|
+
= delete;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @brief Deleted move assignment operator to prevent moving.
|
|
133
|
+
*/
|
|
134
|
+
deferred_reporter_base&
|
|
135
|
+
operator= (deferred_reporter_base&&)
|
|
136
|
+
= delete;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @brief Destructor for the deferred reporter base.
|
|
140
|
+
*/
|
|
141
|
+
~deferred_reporter_base ();
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @brief Appends a message to the reporter.
|
|
145
|
+
*
|
|
146
|
+
* @tparam T The type of the message to append.
|
|
147
|
+
*
|
|
148
|
+
* @param msg The message to append.
|
|
149
|
+
* @return Reference to the current reporter instance.
|
|
150
|
+
*/
|
|
151
|
+
template <class T>
|
|
152
|
+
requires type_traits::printable<T>
|
|
153
|
+
auto&
|
|
154
|
+
operator<< (const T& msg);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @brief Retrieves the result value.
|
|
158
|
+
*
|
|
159
|
+
* @par Parameters
|
|
160
|
+
* None.
|
|
161
|
+
* @retval true The reported condition was met.
|
|
162
|
+
* @retval false The reported condition was not met.
|
|
163
|
+
*/
|
|
164
|
+
[[nodiscard]] bool
|
|
165
|
+
value () const;
|
|
166
|
+
|
|
167
|
+
protected:
|
|
168
|
+
/**
|
|
169
|
+
* @brief Stores the result value of the report.
|
|
170
|
+
*/
|
|
171
|
+
bool value_{};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @brief Indicates whether the reporting should abort further
|
|
175
|
+
* processing.
|
|
176
|
+
*/
|
|
177
|
+
bool abort_ = false;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @brief Indicates whether the reporter has an associated expression.
|
|
181
|
+
*/
|
|
182
|
+
bool has_expression_ = false;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @brief Stores the source location associated with the report.
|
|
186
|
+
*/
|
|
187
|
+
const reflection::source_location location_{};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @brief String to collect the expectation message passed via
|
|
191
|
+
* `operator<<()`.
|
|
192
|
+
*/
|
|
193
|
+
std::string deferred_output_{};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @brief Reference to the test case invoking this report.
|
|
197
|
+
*/
|
|
198
|
+
subtest& subtest_;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// ========================================================================
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @brief Deferred reporter class for a specific expression.
|
|
205
|
+
*
|
|
206
|
+
* @details
|
|
207
|
+
* The `deferred_reporter` class extends `deferred_reporter_base`
|
|
208
|
+
* to provide deferred reporting functionality for a specific test
|
|
209
|
+
* expression within the framework.
|
|
210
|
+
*
|
|
211
|
+
* This class is responsible for capturing the expression under
|
|
212
|
+
* evaluation, the abort status, and the source location. It is intended
|
|
213
|
+
* exclusively for internal use and is implemented in the
|
|
214
|
+
* `include/micro-os-plus/micro-test-plus` folder to ensure a structured
|
|
215
|
+
* and modular codebase.
|
|
216
|
+
*
|
|
217
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
218
|
+
*/
|
|
219
|
+
class deferred_reporter : public deferred_reporter_base
|
|
220
|
+
{
|
|
221
|
+
public:
|
|
222
|
+
/**
|
|
223
|
+
* @brief Constructs a deferred reporter for a specific expression.
|
|
224
|
+
*
|
|
225
|
+
* @param expr The expression under evaluation.
|
|
226
|
+
* @param abort Indicates whether reporting should abort further
|
|
227
|
+
* processing.
|
|
228
|
+
* @param location The source location relevant to the report.
|
|
229
|
+
* @param subtest The subtest that owns this deferred report.
|
|
230
|
+
* @param expression The expression formatter to format the expression
|
|
231
|
+
* text.
|
|
232
|
+
*/
|
|
233
|
+
template <class Expr_T>
|
|
234
|
+
deferred_reporter (const Expr_T& expr, bool abort,
|
|
235
|
+
const reflection::source_location& location,
|
|
236
|
+
subtest& subtest, expression_formatter& expression);
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @brief Destructor for the deferred reporter.
|
|
240
|
+
*/
|
|
241
|
+
~deferred_reporter () = default;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// ------------------------------------------------------------------------
|
|
245
|
+
} // namespace detail
|
|
246
|
+
|
|
247
|
+
// --------------------------------------------------------------------------
|
|
248
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
249
|
+
|
|
250
|
+
#if defined(__GNUC__)
|
|
251
|
+
#pragma GCC diagnostic pop
|
|
252
|
+
#endif
|
|
253
|
+
|
|
254
|
+
// ----------------------------------------------------------------------------
|
|
255
|
+
|
|
256
|
+
#endif // __cplusplus
|
|
257
|
+
|
|
258
|
+
// ============================================================================
|
|
259
|
+
// Templates & constexpr implementations.
|
|
260
|
+
|
|
261
|
+
#include "inlines/deferred-reporter-inlines.h"
|
|
262
|
+
|
|
263
|
+
// ----------------------------------------------------------------------------
|
|
264
|
+
|
|
265
|
+
#endif // MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
|
|
266
|
+
|
|
267
|
+
// ----------------------------------------------------------------------------
|