@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,289 @@
|
|
|
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 non-template implementations for the µTest++
|
|
21
|
+
* expression formatter.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This source file contains the non-template `operator<<` overloads of
|
|
25
|
+
* `expression_formatter` for all standard arithmetic, character, string,
|
|
26
|
+
* boolean, and null-pointer types. Each overload appends the formatted
|
|
27
|
+
* value — together with an appropriate type suffix where applicable — to
|
|
28
|
+
* the internal string buffer.
|
|
29
|
+
*
|
|
30
|
+
* All definitions reside within the
|
|
31
|
+
* `micro_os_plus::micro_test_plus` namespace.
|
|
32
|
+
*
|
|
33
|
+
* This file must be included when building the µTest++ library.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
// ----------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
39
|
+
#include <micro-os-plus/config.h>
|
|
40
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
41
|
+
|
|
42
|
+
#include "micro-os-plus/micro-test-plus/expression-formatter.h"
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#if defined(__GNUC__)
|
|
47
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
48
|
+
#if defined(__clang__)
|
|
49
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
50
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
51
|
+
#endif
|
|
52
|
+
#endif
|
|
53
|
+
|
|
54
|
+
// ============================================================================
|
|
55
|
+
|
|
56
|
+
namespace micro_os_plus::micro_test_plus::detail
|
|
57
|
+
{
|
|
58
|
+
// --------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @details
|
|
62
|
+
* Appends the contents of the `std::string_view` directly to the
|
|
63
|
+
* internal buffer using `buffer_.append(sv)`.
|
|
64
|
+
*/
|
|
65
|
+
expression_formatter&
|
|
66
|
+
expression_formatter::operator<< (std::string_view sv)
|
|
67
|
+
{
|
|
68
|
+
buffer_.append (sv);
|
|
69
|
+
return *this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @details
|
|
74
|
+
* Appends the single character @p c to the internal buffer using
|
|
75
|
+
* `buffer_.append(1, c)`.
|
|
76
|
+
*/
|
|
77
|
+
expression_formatter&
|
|
78
|
+
expression_formatter::operator<< (char c)
|
|
79
|
+
{
|
|
80
|
+
buffer_.append (1, c);
|
|
81
|
+
return *this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @details
|
|
86
|
+
* Appends the null-terminated C string @p s to the internal buffer
|
|
87
|
+
* using `buffer_.append(s)`.
|
|
88
|
+
*/
|
|
89
|
+
expression_formatter&
|
|
90
|
+
expression_formatter::operator<< (const char* s)
|
|
91
|
+
{
|
|
92
|
+
buffer_.append (s);
|
|
93
|
+
return *this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @details
|
|
98
|
+
* Appends the string `"true"` or `"false"` to the internal buffer
|
|
99
|
+
* based on the value of @p v.
|
|
100
|
+
*/
|
|
101
|
+
expression_formatter&
|
|
102
|
+
expression_formatter::operator<< (bool v)
|
|
103
|
+
{
|
|
104
|
+
buffer_.append (v ? "true" : "false");
|
|
105
|
+
return *this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @details
|
|
110
|
+
* Appends the string `"nullptr"` to the internal buffer.
|
|
111
|
+
*/
|
|
112
|
+
expression_formatter&
|
|
113
|
+
expression_formatter::operator<< (std::nullptr_t)
|
|
114
|
+
{
|
|
115
|
+
buffer_.append ("nullptr");
|
|
116
|
+
return *this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @details
|
|
121
|
+
* Converts @p c to its decimal string representation via
|
|
122
|
+
* `append_number_()` and appends the type suffix `"c"`.
|
|
123
|
+
*/
|
|
124
|
+
expression_formatter&
|
|
125
|
+
expression_formatter::operator<< (signed char c)
|
|
126
|
+
{
|
|
127
|
+
detail::append_number_ (buffer_, c);
|
|
128
|
+
buffer_.append ("c");
|
|
129
|
+
return *this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @details
|
|
134
|
+
* Converts @p c to its decimal string representation via
|
|
135
|
+
* `append_number_()` and appends the type suffix `"uc"`.
|
|
136
|
+
*/
|
|
137
|
+
expression_formatter&
|
|
138
|
+
expression_formatter::operator<< (unsigned char c)
|
|
139
|
+
{
|
|
140
|
+
detail::append_number_ (buffer_, c);
|
|
141
|
+
buffer_.append ("uc");
|
|
142
|
+
return *this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @details
|
|
147
|
+
* Converts @p v to its decimal string representation via
|
|
148
|
+
* `append_number_()` and appends the type suffix `"s"`.
|
|
149
|
+
*/
|
|
150
|
+
expression_formatter&
|
|
151
|
+
expression_formatter::operator<< (signed short v)
|
|
152
|
+
{
|
|
153
|
+
detail::append_number_ (buffer_, v);
|
|
154
|
+
buffer_.append ("s");
|
|
155
|
+
return *this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @details
|
|
160
|
+
* Converts @p v to its decimal string representation via
|
|
161
|
+
* `append_number_()` and appends the type suffix `"us"`.
|
|
162
|
+
*/
|
|
163
|
+
expression_formatter&
|
|
164
|
+
expression_formatter::operator<< (unsigned short v)
|
|
165
|
+
{
|
|
166
|
+
detail::append_number_ (buffer_, v);
|
|
167
|
+
buffer_.append ("us");
|
|
168
|
+
return *this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @details
|
|
173
|
+
* Converts @p v to its decimal string representation via
|
|
174
|
+
* `append_number_()` without a type suffix.
|
|
175
|
+
*/
|
|
176
|
+
expression_formatter&
|
|
177
|
+
expression_formatter::operator<< (signed int v)
|
|
178
|
+
{
|
|
179
|
+
detail::append_number_ (buffer_, v);
|
|
180
|
+
return *this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @details
|
|
185
|
+
* Converts @p v to its decimal string representation via
|
|
186
|
+
* `append_number_()` and appends the type suffix `"u"`.
|
|
187
|
+
*/
|
|
188
|
+
expression_formatter&
|
|
189
|
+
expression_formatter::operator<< (unsigned int v)
|
|
190
|
+
{
|
|
191
|
+
detail::append_number_ (buffer_, v);
|
|
192
|
+
buffer_.append ("u");
|
|
193
|
+
return *this;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @details
|
|
198
|
+
* Converts @p v to its decimal string representation via
|
|
199
|
+
* `append_number_()` and appends the type suffix `"l"`.
|
|
200
|
+
*/
|
|
201
|
+
expression_formatter&
|
|
202
|
+
expression_formatter::operator<< (signed long v)
|
|
203
|
+
{
|
|
204
|
+
detail::append_number_ (buffer_, v);
|
|
205
|
+
buffer_.append ("l");
|
|
206
|
+
return *this;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @details
|
|
211
|
+
* Converts @p v to its decimal string representation via
|
|
212
|
+
* `append_number_()` and appends the type suffix `"ul"`.
|
|
213
|
+
*/
|
|
214
|
+
expression_formatter&
|
|
215
|
+
expression_formatter::operator<< (unsigned long v)
|
|
216
|
+
{
|
|
217
|
+
detail::append_number_ (buffer_, v);
|
|
218
|
+
buffer_.append ("ul");
|
|
219
|
+
return *this;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @details
|
|
224
|
+
* Converts @p v to its decimal string representation via
|
|
225
|
+
* `append_number_()` and appends the type suffix `"ll"`.
|
|
226
|
+
*/
|
|
227
|
+
expression_formatter&
|
|
228
|
+
expression_formatter::operator<< (signed long long v)
|
|
229
|
+
{
|
|
230
|
+
detail::append_number_ (buffer_, v);
|
|
231
|
+
buffer_.append ("ll");
|
|
232
|
+
return *this;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @details
|
|
237
|
+
* Converts @p v to its decimal string representation via
|
|
238
|
+
* `append_number_()` and appends the type suffix `"ull"`.
|
|
239
|
+
*/
|
|
240
|
+
expression_formatter&
|
|
241
|
+
expression_formatter::operator<< (unsigned long long v)
|
|
242
|
+
{
|
|
243
|
+
detail::append_number_ (buffer_, v);
|
|
244
|
+
buffer_.append ("ull");
|
|
245
|
+
return *this;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @details
|
|
250
|
+
* Converts @p v to its string representation via `append_number_()`
|
|
251
|
+
* and appends the type suffix `"f"`.
|
|
252
|
+
*/
|
|
253
|
+
expression_formatter&
|
|
254
|
+
expression_formatter::operator<< (float v)
|
|
255
|
+
{
|
|
256
|
+
detail::append_number_ (buffer_, v);
|
|
257
|
+
buffer_.append ("f");
|
|
258
|
+
return *this;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @details
|
|
263
|
+
* Converts @p v to its string representation via `append_number_()`
|
|
264
|
+
* without a type suffix.
|
|
265
|
+
*/
|
|
266
|
+
expression_formatter&
|
|
267
|
+
expression_formatter::operator<< (double v)
|
|
268
|
+
{
|
|
269
|
+
detail::append_number_ (buffer_, v);
|
|
270
|
+
return *this;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @details
|
|
275
|
+
* Converts @p v to its string representation via `append_number_()`
|
|
276
|
+
* and appends the type suffix `"l"`.
|
|
277
|
+
*/
|
|
278
|
+
expression_formatter&
|
|
279
|
+
expression_formatter::operator<< (long double v)
|
|
280
|
+
{
|
|
281
|
+
detail::append_number_ (buffer_, v);
|
|
282
|
+
buffer_.append ("l");
|
|
283
|
+
return *this;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// --------------------------------------------------------------------------
|
|
287
|
+
} // namespace micro_os_plus::micro_test_plus::detail
|
|
288
|
+
|
|
289
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
#include <cstring>
|
|
37
|
+
|
|
38
|
+
#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
|
|
39
|
+
#include <micro-os-plus/config.h>
|
|
40
|
+
#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
|
|
41
|
+
|
|
42
|
+
#include "micro-os-plus/micro-test-plus/reflection.h"
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#if defined(__GNUC__)
|
|
47
|
+
#if defined(__clang__)
|
|
48
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
49
|
+
#endif
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
// ============================================================================
|
|
53
|
+
|
|
54
|
+
namespace micro_os_plus::micro_test_plus
|
|
55
|
+
{
|
|
56
|
+
// --------------------------------------------------------------------------
|
|
57
|
+
// Public API.
|
|
58
|
+
|
|
59
|
+
// --------------------------------------------------------------------------
|
|
60
|
+
// Too small to deserve a separate source file.
|
|
61
|
+
namespace reflection
|
|
62
|
+
{
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @details
|
|
66
|
+
* This function extracts the short name from a given file path by locating
|
|
67
|
+
* the final folder separator ('/'). If a separator is found, it returns a
|
|
68
|
+
* pointer to the character immediately following it, effectively providing
|
|
69
|
+
* the file or folder name. If no separator is present, the original input
|
|
70
|
+
* string is returned. This utility is useful for reporting concise file or
|
|
71
|
+
* folder names in test output.
|
|
72
|
+
*/
|
|
73
|
+
const char*
|
|
74
|
+
short_name (const char* name) noexcept
|
|
75
|
+
{
|
|
76
|
+
#if defined(__GNUC__)
|
|
77
|
+
#pragma GCC diagnostic push
|
|
78
|
+
#if defined(__clang__)
|
|
79
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
80
|
+
#endif
|
|
81
|
+
#endif
|
|
82
|
+
const char* p = strrchr (name, '/');
|
|
83
|
+
if (p != nullptr)
|
|
84
|
+
return p + 1;
|
|
85
|
+
else
|
|
86
|
+
return name;
|
|
87
|
+
#if defined(__GNUC__)
|
|
88
|
+
#pragma GCC diagnostic pop
|
|
89
|
+
#endif
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
} // namespace reflection
|
|
93
|
+
|
|
94
|
+
// ==========================================================================
|
|
95
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
96
|
+
|
|
97
|
+
// ----------------------------------------------------------------------------
|