@micro-os-plus/micro-test-plus 3.2.0 → 3.2.3
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 +502 -11
- package/CMakeLists.txt +33 -32
- package/LICENSE +1 -1
- package/README.md +15 -14
- package/config/xcdl-build.json +32 -0
- package/include/micro-os-plus/micro-test-plus/detail.h +1885 -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 +471 -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.h +801 -0
- package/include/micro-os-plus/micro-test-plus/test-runner.h +241 -0
- package/include/micro-os-plus/micro-test-plus/test-suite.h +456 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
- package/include/micro-os-plus/micro-test-plus.h +171 -554
- package/meson.build +6 -7
- package/package.json +40 -32
- package/src/micro-test-plus.cpp +143 -42
- package/src/test-reporter.cpp +350 -9
- package/src/test-runner.cpp +77 -14
- package/src/test-suite.cpp +132 -14
- package/LICENSE-Boost +0 -23
- package/include/micro-os-plus/detail.h +0 -766
- package/include/micro-os-plus/inlines.h +0 -204
- package/include/micro-os-plus/literals.h +0 -513
- package/include/micro-os-plus/math.h +0 -205
- package/include/micro-os-plus/reflection.h +0 -139
- package/include/micro-os-plus/test-reporter-inlines.h +0 -231
- package/include/micro-os-plus/test-reporter.h +0 -357
- package/include/micro-os-plus/test-runner.h +0 -133
- package/include/micro-os-plus/test-suite.h +0 -307
- package/include/micro-os-plus/type-traits.h +0 -390
|
@@ -0,0 +1,912 @@
|
|
|
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++ user-defined
|
|
21
|
+
* literals and type wrappers.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the declarations for the user-defined literal operators
|
|
25
|
+
* and type wrappers used within the µTest++ framework. It defines interfaces
|
|
26
|
+
* for generating strongly-typed integral, floating-point, and boolean
|
|
27
|
+
* constants at compile time, enabling expressive and type-safe test
|
|
28
|
+
* expressions.
|
|
29
|
+
*
|
|
30
|
+
* The declared literal operators support a wide range of C++ fundamental
|
|
31
|
+
* types, allowing constants to be suffixed with type-specific identifiers
|
|
32
|
+
* (such as `_i`, `_u16`, `_f`, `_d`, `_b`, etc.) to produce values that
|
|
33
|
+
* integrate seamlessly with the µTest++ comparators and reporting mechanisms.
|
|
34
|
+
*
|
|
35
|
+
* In addition to literal operators, this header declares both deprecated and
|
|
36
|
+
* modern type wrappers for explicit type conversion, supporting enhanced
|
|
37
|
+
* clarity and type safety in test conditions. The preferred `to_*` forms are
|
|
38
|
+
* recommended for new code, while the older `_i`, `_u8`, etc. aliases are
|
|
39
|
+
* retained for backwards compatibility.
|
|
40
|
+
*
|
|
41
|
+
* All definitions reside within the `micro_os_plus::micro_test_plus::literals`
|
|
42
|
+
* namespace, ensuring clear separation from user code and minimising the risk
|
|
43
|
+
* of naming conflicts.
|
|
44
|
+
*
|
|
45
|
+
* The header files are organised within the
|
|
46
|
+
* `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
|
|
47
|
+
* modular codebase.
|
|
48
|
+
*
|
|
49
|
+
* This file is intended for internal use within the framework and should not
|
|
50
|
+
* be included directly by user code.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
#ifndef MICRO_TEST_PLUS_LITERALS_H_
|
|
54
|
+
#define MICRO_TEST_PLUS_LITERALS_H_
|
|
55
|
+
|
|
56
|
+
// ----------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
#ifdef __cplusplus
|
|
59
|
+
|
|
60
|
+
// ----------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
#include <cstdint>
|
|
63
|
+
#include "type-traits.h"
|
|
64
|
+
#include "math.h"
|
|
65
|
+
|
|
66
|
+
// ----------------------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
#if defined(__GNUC__)
|
|
69
|
+
#pragma GCC diagnostic push
|
|
70
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
71
|
+
#if defined(__clang__)
|
|
72
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
73
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
74
|
+
#endif
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
namespace micro_os_plus::micro_test_plus
|
|
78
|
+
{
|
|
79
|
+
// --------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @namespace micro_os_plus::micro_test_plus::literals
|
|
83
|
+
* @brief User-defined literals and type wrappers for the µTest++ testing
|
|
84
|
+
* framework.
|
|
85
|
+
*
|
|
86
|
+
* @details
|
|
87
|
+
* The `literals` namespace provides an extensive collection of user-defined
|
|
88
|
+
* literal operators and type wrappers, enabling explicit specification
|
|
89
|
+
* of operand types for use with the µTest++ comparators and operators.
|
|
90
|
+
*
|
|
91
|
+
* These operators allow constants to be suffixed (for example, `1_i`,
|
|
92
|
+
* `2_u16`) to produce strongly-typed values, thereby enhancing type safety
|
|
93
|
+
* and ensuring that comparator functions and operators can display actual
|
|
94
|
+
* values in test reports.
|
|
95
|
+
*
|
|
96
|
+
* In addition to literals, the namespace includes wrappers for converting
|
|
97
|
+
* dynamic values and expressions to recognised types, both via deprecated
|
|
98
|
+
* aliases (such as `_i`, `_u8`) and the preferred `to_*` forms (such as
|
|
99
|
+
* `to_i`, `to_u8`).
|
|
100
|
+
*
|
|
101
|
+
* All definitions within this namespace are intended to facilitate clear and
|
|
102
|
+
* type-safe test expressions, and are implemented in the
|
|
103
|
+
* `include/micro-os-plus` folder to maintain a structured and modular
|
|
104
|
+
* codebase.
|
|
105
|
+
*/
|
|
106
|
+
namespace literals
|
|
107
|
+
{
|
|
108
|
+
/**
|
|
109
|
+
* @ingroup micro-test-plus-literals
|
|
110
|
+
* @brief User-defined literal operator to convert to `int`.
|
|
111
|
+
*
|
|
112
|
+
* @tparam Cs The character pack representing the digits of the integer
|
|
113
|
+
* constant.
|
|
114
|
+
*
|
|
115
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
116
|
+
* `int` value.
|
|
117
|
+
*/
|
|
118
|
+
template <char... Cs>
|
|
119
|
+
[[nodiscard]] constexpr auto
|
|
120
|
+
operator""_i ();
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @ingroup micro-test-plus-literals
|
|
124
|
+
* @brief User-defined literal operator to convert to `short`.
|
|
125
|
+
*
|
|
126
|
+
* @tparam Cs The character pack representing the digits of the integer
|
|
127
|
+
* constant.
|
|
128
|
+
*
|
|
129
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
130
|
+
* `short` value.
|
|
131
|
+
*/
|
|
132
|
+
template <char... Cs>
|
|
133
|
+
[[nodiscard]] constexpr auto
|
|
134
|
+
operator""_s ();
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @ingroup micro-test-plus-literals
|
|
138
|
+
* @brief User-defined literal operator to convert to `char`.
|
|
139
|
+
*
|
|
140
|
+
* @tparam Cs The character pack representing the digits of the character
|
|
141
|
+
* constant.
|
|
142
|
+
*
|
|
143
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
144
|
+
* `char` value.
|
|
145
|
+
*/
|
|
146
|
+
template <char... Cs>
|
|
147
|
+
[[nodiscard]] constexpr auto
|
|
148
|
+
operator""_c ();
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @ingroup micro-test-plus-literals
|
|
152
|
+
* @brief User-defined literal operator to convert to `signed char`.
|
|
153
|
+
*
|
|
154
|
+
* @tparam Cs The character pack representing the digits of the signed
|
|
155
|
+
* character constant.
|
|
156
|
+
*
|
|
157
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
158
|
+
* `signed char` value.
|
|
159
|
+
*/
|
|
160
|
+
template <char... Cs>
|
|
161
|
+
[[nodiscard]] constexpr auto
|
|
162
|
+
operator""_sc ();
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @ingroup micro-test-plus-literals
|
|
166
|
+
* @brief User-defined literal operator to convert to `long`.
|
|
167
|
+
*
|
|
168
|
+
* @tparam Cs The character pack representing the digits of the long
|
|
169
|
+
* integer constant.
|
|
170
|
+
*
|
|
171
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
172
|
+
* `long` value.
|
|
173
|
+
*/
|
|
174
|
+
template <char... Cs>
|
|
175
|
+
[[nodiscard]] constexpr auto
|
|
176
|
+
operator""_l ();
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @ingroup micro-test-plus-literals
|
|
180
|
+
* @brief User-defined literal operator to convert to `long long`.
|
|
181
|
+
*
|
|
182
|
+
* @tparam Cs The character pack representing the digits of the long long
|
|
183
|
+
* integer constant.
|
|
184
|
+
*
|
|
185
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
186
|
+
* `long long` value.
|
|
187
|
+
*/
|
|
188
|
+
template <char... Cs>
|
|
189
|
+
[[nodiscard]] constexpr auto
|
|
190
|
+
operator""_ll ();
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @ingroup micro-test-plus-literals
|
|
194
|
+
* @brief User-defined literal operator to convert to `unsigned`.
|
|
195
|
+
*
|
|
196
|
+
* @tparam Cs The character pack representing the digits of the unsigned
|
|
197
|
+
* integer constant.
|
|
198
|
+
*
|
|
199
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
200
|
+
* `unsigned` value.
|
|
201
|
+
*/
|
|
202
|
+
template <char... Cs>
|
|
203
|
+
[[nodiscard]] constexpr auto
|
|
204
|
+
operator""_u ();
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @ingroup micro-test-plus-literals
|
|
208
|
+
* @brief User-defined literal operator to convert to `unsigned char`.
|
|
209
|
+
*
|
|
210
|
+
* @tparam Cs The character pack representing the digits of the unsigned
|
|
211
|
+
* character constant.
|
|
212
|
+
*
|
|
213
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
214
|
+
* `unsigned char` value.
|
|
215
|
+
*/
|
|
216
|
+
template <char... Cs>
|
|
217
|
+
[[nodiscard]] constexpr auto
|
|
218
|
+
operator""_uc ();
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @ingroup micro-test-plus-literals
|
|
222
|
+
* @brief User-defined literal operator to convert to `unsigned short`.
|
|
223
|
+
*
|
|
224
|
+
* @tparam Cs The character pack representing the digits of the unsigned
|
|
225
|
+
* short constant.
|
|
226
|
+
*
|
|
227
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
228
|
+
* `unsigned short` value.
|
|
229
|
+
*/
|
|
230
|
+
template <char... Cs>
|
|
231
|
+
[[nodiscard]] constexpr auto
|
|
232
|
+
operator""_us ();
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @ingroup micro-test-plus-literals
|
|
236
|
+
* @brief User-defined literal operator to convert to `unsigned long`.
|
|
237
|
+
*
|
|
238
|
+
* @tparam Cs The character pack representing the digits of the unsigned
|
|
239
|
+
* long integer constant.
|
|
240
|
+
*
|
|
241
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
242
|
+
* `unsigned long` value.
|
|
243
|
+
*/
|
|
244
|
+
template <char... Cs>
|
|
245
|
+
[[nodiscard]] constexpr auto
|
|
246
|
+
operator""_ul ();
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @ingroup micro-test-plus-literals
|
|
250
|
+
* @brief User-defined literal operator to convert to `unsigned long long`.
|
|
251
|
+
*
|
|
252
|
+
* @tparam Cs The character pack representing the digits of the unsigned
|
|
253
|
+
* long long integer constant.
|
|
254
|
+
*
|
|
255
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
256
|
+
* `unsigned long long` value.
|
|
257
|
+
*/
|
|
258
|
+
template <char... Cs>
|
|
259
|
+
[[nodiscard]] constexpr auto
|
|
260
|
+
operator""_ull ();
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* @ingroup micro-test-plus-literals
|
|
264
|
+
* @brief User-defined literal operator to convert to `int8_t`.
|
|
265
|
+
*
|
|
266
|
+
* @tparam Cs The character pack representing the digits of the `int8_t`
|
|
267
|
+
* constant.
|
|
268
|
+
*
|
|
269
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
270
|
+
* `int8_t` value.
|
|
271
|
+
*/
|
|
272
|
+
template <char... Cs>
|
|
273
|
+
[[nodiscard]] constexpr auto
|
|
274
|
+
operator""_i8 ();
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @ingroup micro-test-plus-literals
|
|
278
|
+
* @brief User-defined literal operator to convert to `int16_t`.
|
|
279
|
+
*
|
|
280
|
+
* @tparam Cs The character pack representing the digits of the `int16_t`
|
|
281
|
+
* constant.
|
|
282
|
+
*
|
|
283
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
284
|
+
* `int16_t` value.
|
|
285
|
+
*/
|
|
286
|
+
template <char... Cs>
|
|
287
|
+
[[nodiscard]] constexpr auto
|
|
288
|
+
operator""_i16 ();
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @ingroup micro-test-plus-literals
|
|
292
|
+
* @brief User-defined literal operator to convert to `int32_t`.
|
|
293
|
+
*
|
|
294
|
+
* @tparam Cs The character pack representing the digits of the `int32_t`
|
|
295
|
+
* constant.
|
|
296
|
+
*
|
|
297
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
298
|
+
* `int32_t` value.
|
|
299
|
+
*/
|
|
300
|
+
template <char... Cs>
|
|
301
|
+
[[nodiscard]] constexpr auto
|
|
302
|
+
operator""_i32 ();
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @ingroup micro-test-plus-literals
|
|
306
|
+
* @brief User-defined literal operator to convert to `int64_t`.
|
|
307
|
+
*
|
|
308
|
+
* @tparam Cs The character pack representing the digits of the `int64_t`
|
|
309
|
+
* constant.
|
|
310
|
+
*
|
|
311
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
312
|
+
* `int64_t` value.
|
|
313
|
+
*/
|
|
314
|
+
template <char... Cs>
|
|
315
|
+
[[nodiscard]] constexpr auto
|
|
316
|
+
operator""_i64 ();
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @ingroup micro-test-plus-literals
|
|
320
|
+
* @brief User-defined literal operator to convert to `uint8_t`.
|
|
321
|
+
*
|
|
322
|
+
* @tparam Cs The character pack representing the digits of the `uint8_t`
|
|
323
|
+
* constant.
|
|
324
|
+
*
|
|
325
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
326
|
+
* `uint8_t` value.
|
|
327
|
+
* and reporting mechanisms.
|
|
328
|
+
*/
|
|
329
|
+
template <char... Cs>
|
|
330
|
+
[[nodiscard]] constexpr auto
|
|
331
|
+
operator""_u8 ();
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @ingroup micro-test-plus-literals
|
|
335
|
+
* @brief User-defined literal operator to convert to `uint16_t`.
|
|
336
|
+
*
|
|
337
|
+
* @tparam Cs The character pack representing the digits of the `uint16_t`
|
|
338
|
+
* constant.
|
|
339
|
+
*
|
|
340
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
341
|
+
* `uint16_t` value.
|
|
342
|
+
*/
|
|
343
|
+
template <char... Cs>
|
|
344
|
+
[[nodiscard]] constexpr auto
|
|
345
|
+
operator""_u16 ();
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @ingroup micro-test-plus-literals
|
|
349
|
+
* @brief User-defined literal operator to convert to `uint32_t`.
|
|
350
|
+
*
|
|
351
|
+
* @tparam Cs The character pack representing the digits of the `uint32_t`
|
|
352
|
+
* constant.
|
|
353
|
+
*
|
|
354
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
355
|
+
* `uint32_t` value.
|
|
356
|
+
*/
|
|
357
|
+
template <char... Cs>
|
|
358
|
+
[[nodiscard]] constexpr auto
|
|
359
|
+
operator""_u32 ();
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @ingroup micro-test-plus-literals
|
|
363
|
+
* @brief User-defined literal operator to convert to `uint64_t`.
|
|
364
|
+
*
|
|
365
|
+
* @tparam Cs The character pack representing the digits of the `uint64_t`
|
|
366
|
+
* constant.
|
|
367
|
+
*
|
|
368
|
+
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
369
|
+
* `uint64_t` value.
|
|
370
|
+
*/
|
|
371
|
+
template <char... Cs>
|
|
372
|
+
[[nodiscard]] constexpr auto
|
|
373
|
+
operator""_u64 ();
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @ingroup micro-test-plus-literals
|
|
377
|
+
* @brief User-defined literal operator to convert to `float`.
|
|
378
|
+
*
|
|
379
|
+
* @tparam Cs The character pack representing the digits of the
|
|
380
|
+
* floating-point constant.
|
|
381
|
+
*
|
|
382
|
+
* @return A `type_traits::floating_point_constant` instance holding the
|
|
383
|
+
* parsed `float` value.
|
|
384
|
+
*/
|
|
385
|
+
template <char... Cs>
|
|
386
|
+
[[nodiscard]] constexpr auto
|
|
387
|
+
operator""_f ();
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* @ingroup micro-test-plus-literals
|
|
391
|
+
* @brief User-defined literal operator to convert to `double`.
|
|
392
|
+
*
|
|
393
|
+
* @tparam Cs The character pack representing the digits of the
|
|
394
|
+
* floating-point constant.
|
|
395
|
+
*
|
|
396
|
+
* @return A `type_traits::floating_point_constant` instance holding the
|
|
397
|
+
* parsed `double` value.
|
|
398
|
+
*/
|
|
399
|
+
template <char... Cs>
|
|
400
|
+
[[nodiscard]] constexpr auto
|
|
401
|
+
operator""_d ();
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @ingroup micro-test-plus-literals
|
|
405
|
+
* @brief User-defined literal operator to convert to `long double`.
|
|
406
|
+
*
|
|
407
|
+
* @tparam Cs The character pack representing the digits of the
|
|
408
|
+
* floating-point constant.
|
|
409
|
+
*
|
|
410
|
+
* @return A `type_traits::floating_point_constant` instance holding the
|
|
411
|
+
* parsed `long double` value.
|
|
412
|
+
*/
|
|
413
|
+
template <char... Cs>
|
|
414
|
+
[[nodiscard]] constexpr auto
|
|
415
|
+
operator""_ld ();
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @ingroup micro-test-plus-literals
|
|
419
|
+
* @brief User-defined literal operator to convert to `bool`.
|
|
420
|
+
*
|
|
421
|
+
* @param name Pointer to the character sequence representing the literal.
|
|
422
|
+
* @param size The size of the character sequence.
|
|
423
|
+
* @return An instance of a wrapper type convertible to `bool` and
|
|
424
|
+
* supporting equality comparisons.
|
|
425
|
+
*/
|
|
426
|
+
constexpr auto
|
|
427
|
+
operator""_b (const char* name, decltype (sizeof ("")) size);
|
|
428
|
+
|
|
429
|
+
// ------------------------------------------------------------------------
|
|
430
|
+
} // namespace literals
|
|
431
|
+
|
|
432
|
+
// --------------------------------------------------------------------------
|
|
433
|
+
|
|
434
|
+
#if defined(__GNUC__)
|
|
435
|
+
#pragma GCC diagnostic push
|
|
436
|
+
#if defined(__clang__)
|
|
437
|
+
#pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"
|
|
438
|
+
#endif
|
|
439
|
+
#endif
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* @addtogroup micro-test-plus-literals
|
|
443
|
+
* @{
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* @name Deprecated Type Wrappers
|
|
448
|
+
* @brief Strongly-typed wrappers for explicit type conversion.
|
|
449
|
+
*
|
|
450
|
+
* @details
|
|
451
|
+
* These type aliases provide wrappers for converting values and expressions
|
|
452
|
+
* to specific types for use with µTest++ comparators and test expressions.
|
|
453
|
+
*
|
|
454
|
+
* The `_i`, `_u8`, etc. forms are now deprecated as of version 3.2.0. Please
|
|
455
|
+
* use the preferred `to_*` type wrappers for new code, as they offer
|
|
456
|
+
* improved clarity and consistency.
|
|
457
|
+
*
|
|
458
|
+
* @par Deprecated
|
|
459
|
+
* Use the corresponding `to_*` type wrappers instead
|
|
460
|
+
* (since 3.2.0).
|
|
461
|
+
*/
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* @brief Strongly-typed wrapper for `bool` values.
|
|
465
|
+
*
|
|
466
|
+
* @deprecated Use @c to_b (since 3.2.0).
|
|
467
|
+
*/
|
|
468
|
+
using _b = type_traits::value<bool>;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* @brief Strongly-typed wrapper for `char` values.
|
|
472
|
+
*
|
|
473
|
+
* @deprecated Use @c to_c (since 3.2.0).
|
|
474
|
+
*/
|
|
475
|
+
using _c = type_traits::value<char>;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* @brief Strongly-typed wrapper for `signed char` values.
|
|
479
|
+
*
|
|
480
|
+
* @deprecated Use @c to_sc (since 3.2.0).
|
|
481
|
+
*/
|
|
482
|
+
using _sc = type_traits::value<signed char>;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @brief Strongly-typed wrapper for `short` values.
|
|
486
|
+
*
|
|
487
|
+
* @deprecated Use @c to_s (since 3.2.0).
|
|
488
|
+
*/
|
|
489
|
+
using _s = type_traits::value<short>;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @brief Strongly-typed wrapper for `int` values.
|
|
493
|
+
*
|
|
494
|
+
* @deprecated Use @c to_i (since 3.2.0).
|
|
495
|
+
*/
|
|
496
|
+
using _i = type_traits::value<int>;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @brief Strongly-typed wrapper for `long` values.
|
|
500
|
+
*
|
|
501
|
+
* @deprecated Use @c to_l (since 3.2.0).
|
|
502
|
+
*/
|
|
503
|
+
using _l = type_traits::value<long>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* @brief Strongly-typed wrapper for `long long` values.
|
|
507
|
+
*
|
|
508
|
+
* @deprecated Use @c to_ll (since 3.2.0).
|
|
509
|
+
*/
|
|
510
|
+
using _ll = type_traits::value<long long>;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @brief Strongly-typed wrapper for `unsigned` values.
|
|
514
|
+
*
|
|
515
|
+
* @deprecated Use @c to_u (since 3.2.0).
|
|
516
|
+
*/
|
|
517
|
+
using _u = type_traits::value<unsigned>;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @brief Strongly-typed wrapper for `unsigned char` values.
|
|
521
|
+
*
|
|
522
|
+
* @deprecated Use @c to_uc (since 3.2.0).
|
|
523
|
+
*/
|
|
524
|
+
using _uc = type_traits::value<unsigned char>;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @brief Strongly-typed wrapper for `unsigned short` values.
|
|
528
|
+
*
|
|
529
|
+
* @deprecated Use @c to_us (since 3.2.0).
|
|
530
|
+
*/
|
|
531
|
+
using _us = type_traits::value<unsigned short>;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @brief Strongly-typed wrapper for `unsigned long` values.
|
|
535
|
+
*
|
|
536
|
+
* @deprecated Use @c to_ul (since 3.2.0).
|
|
537
|
+
*/
|
|
538
|
+
using _ul = type_traits::value<unsigned long>;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* @brief Strongly-typed wrapper for `unsigned long long` values.
|
|
542
|
+
*
|
|
543
|
+
* @deprecated Use @c to_ull (since 3.2.0).
|
|
544
|
+
*/
|
|
545
|
+
using _ull = type_traits::value<unsigned long long>;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* @brief Strongly-typed wrapper for `std::int8_t` values.
|
|
549
|
+
*
|
|
550
|
+
* @deprecated Use @c to_i8 (since 3.2.0).
|
|
551
|
+
*/
|
|
552
|
+
using _i8 = type_traits::value<std::int8_t>;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @brief Strongly-typed wrapper for `std::int16_t` values.
|
|
556
|
+
*
|
|
557
|
+
* @deprecated Use @c to_i16 (since 3.2.0).
|
|
558
|
+
*/
|
|
559
|
+
using _i16 = type_traits::value<std::int16_t>;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @brief Strongly-typed wrapper for `std::int32_t` values.
|
|
563
|
+
*
|
|
564
|
+
* @deprecated Use @c to_i32 (since 3.2.0).
|
|
565
|
+
*/
|
|
566
|
+
using _i32 = type_traits::value<std::int32_t>;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* @brief Strongly-typed wrapper for `std::int64_t` values.
|
|
570
|
+
*
|
|
571
|
+
* @deprecated Use @c to_i64 (since 3.2.0).
|
|
572
|
+
*/
|
|
573
|
+
using _i64 = type_traits::value<std::int64_t>;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @brief Strongly-typed wrapper for `std::uint8_t` values.
|
|
577
|
+
*
|
|
578
|
+
* @deprecated Use @c to_u8 (since 3.2.0).
|
|
579
|
+
*/
|
|
580
|
+
using _u8 = type_traits::value<std::uint8_t>;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* @brief Strongly-typed wrapper for `std::uint16_t` values.
|
|
584
|
+
*
|
|
585
|
+
* @deprecated Use @c to_u16 (since 3.2.0).
|
|
586
|
+
*/
|
|
587
|
+
using _u16 = type_traits::value<std::uint16_t>;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* @brief Strongly-typed wrapper for `std::uint32_t` values.
|
|
591
|
+
*
|
|
592
|
+
* @deprecated Use @c to_u32 (since 3.2.0).
|
|
593
|
+
*/
|
|
594
|
+
using _u32 = type_traits::value<std::uint32_t>;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* @brief Strongly-typed wrapper for `std::uint64_t` values.
|
|
598
|
+
*
|
|
599
|
+
* @deprecated Use @c to_u64 (since 3.2.0).
|
|
600
|
+
*/
|
|
601
|
+
using _u64 = type_traits::value<std::uint64_t>;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @brief Strongly-typed wrapper for `float` values. @deprecated
|
|
605
|
+
* Use @c to_f (since 3.2.0).
|
|
606
|
+
*/
|
|
607
|
+
using _f = type_traits::value<float>;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* @brief Strongly-typed wrapper for `double` values. @deprecated
|
|
611
|
+
* Use @c to_d (since 3.2.0).
|
|
612
|
+
*/
|
|
613
|
+
using _d = type_traits::value<double>;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* @brief Strongly-typed wrapper for `long double` values.
|
|
617
|
+
*
|
|
618
|
+
* @deprecated Use @c to_ld (since 3.2.0).
|
|
619
|
+
*/
|
|
620
|
+
using _ld = type_traits::value<long double>;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* @brief Deprecated generic strongly-typed wrapper for explicit type
|
|
624
|
+
* conversion.
|
|
625
|
+
*
|
|
626
|
+
* @details
|
|
627
|
+
* The `_t` template provides a public, strongly-typed wrapper for any type
|
|
628
|
+
* `T`, enabling explicit conversion of dynamic values and expressions to a
|
|
629
|
+
* type recognised by the µTest++ comparators and reporting mechanisms.
|
|
630
|
+
*
|
|
631
|
+
* This wrapper inherits from `type_traits::value<T>`, ensuring that the
|
|
632
|
+
* encapsulated value is treated as the specified type within the framework.
|
|
633
|
+
*
|
|
634
|
+
* @deprecated Use `to_t` (since 3.2.0).
|
|
635
|
+
*
|
|
636
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
637
|
+
*/
|
|
638
|
+
template <class T>
|
|
639
|
+
struct _t : type_traits::value<T>
|
|
640
|
+
{
|
|
641
|
+
/**
|
|
642
|
+
* @brief Constructor for the deprecated strongly-typed wrapper.
|
|
643
|
+
*
|
|
644
|
+
* @param t The value to be wrapped and explicitly converted.
|
|
645
|
+
*
|
|
646
|
+
* @details
|
|
647
|
+
* Constructs an `_t` instance by forwarding the provided value to the base
|
|
648
|
+
* `type_traits::value<T>` wrapper.
|
|
649
|
+
*/
|
|
650
|
+
constexpr explicit _t (const T& t) : type_traits::value<T>{ t }
|
|
651
|
+
{
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
#if defined(__GNUC__)
|
|
656
|
+
#pragma GCC diagnostic pop
|
|
657
|
+
#endif
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* @name Type Wrappers
|
|
661
|
+
* @brief Strongly-typed wrappers for converting dynamic values and
|
|
662
|
+
* expressions to specific types recognised by µTest++ comparators.
|
|
663
|
+
*
|
|
664
|
+
* @details
|
|
665
|
+
* These type aliases provide a modern, type-safe mechanism for explicitly
|
|
666
|
+
* converting values to the required types for µTest++ test expressions and
|
|
667
|
+
* comparators. Each alias is a wrapper around `type_traits::value<T>`,
|
|
668
|
+
* ensuring that the value is treated as the specified type within the
|
|
669
|
+
* framework.
|
|
670
|
+
*
|
|
671
|
+
* The `to_*` forms are the preferred approach since version 3.2.0,
|
|
672
|
+
* superseding the older `_i`, `_u8`, etc. aliases, which are now deprecated.
|
|
673
|
+
*
|
|
674
|
+
* @par Example
|
|
675
|
+
*
|
|
676
|
+
* @code
|
|
677
|
+
* int x = 42;
|
|
678
|
+
* auto wrapped = to_i{x}; // Explicitly treat x as an int for test
|
|
679
|
+
* comparison
|
|
680
|
+
* @endcode
|
|
681
|
+
*
|
|
682
|
+
* @since 3.2.0
|
|
683
|
+
*/
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* @brief Strongly-typed wrapper for `bool` values.
|
|
687
|
+
*
|
|
688
|
+
* @since 3.2.0
|
|
689
|
+
*/
|
|
690
|
+
using to_b = type_traits::value<bool>;
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* @brief Strongly-typed wrapper for `char` values.
|
|
694
|
+
*
|
|
695
|
+
* @since 3.2.0
|
|
696
|
+
*/
|
|
697
|
+
using to_c = type_traits::value<char>;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* @brief Strongly-typed wrapper for `signed char` values.
|
|
701
|
+
*
|
|
702
|
+
* @since 3.2.0
|
|
703
|
+
*/
|
|
704
|
+
using to_sc = type_traits::value<signed char>;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* @brief Strongly-typed wrapper for `short` values.
|
|
708
|
+
*
|
|
709
|
+
* @since 3.2.0
|
|
710
|
+
*/
|
|
711
|
+
using to_s = type_traits::value<short>;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* @brief Strongly-typed wrapper for `int` values.
|
|
715
|
+
*
|
|
716
|
+
* @since 3.2.0
|
|
717
|
+
*/
|
|
718
|
+
using to_i = type_traits::value<int>;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* @brief Strongly-typed wrapper for `long` values.
|
|
722
|
+
*
|
|
723
|
+
* @since 3.2.0
|
|
724
|
+
*/
|
|
725
|
+
using to_l = type_traits::value<long>;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* @brief Strongly-typed wrapper for `long long` values.
|
|
729
|
+
*
|
|
730
|
+
* @since 3.2.0
|
|
731
|
+
*/
|
|
732
|
+
using to_ll = type_traits::value<long long>;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* @brief Strongly-typed wrapper for `unsigned` values.
|
|
736
|
+
*
|
|
737
|
+
* @since 3.2.0
|
|
738
|
+
*/
|
|
739
|
+
using to_u = type_traits::value<unsigned>;
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* @brief Strongly-typed wrapper for `unsigned char` values.
|
|
743
|
+
*
|
|
744
|
+
* @since 3.2.0
|
|
745
|
+
*/
|
|
746
|
+
using to_uc = type_traits::value<unsigned char>;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* @brief Strongly-typed wrapper for `unsigned short` values.
|
|
750
|
+
*
|
|
751
|
+
* @since 3.2.0
|
|
752
|
+
*/
|
|
753
|
+
using to_us = type_traits::value<unsigned short>;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* @brief Strongly-typed wrapper for `unsigned long` values.
|
|
757
|
+
*
|
|
758
|
+
* @since 3.2.0
|
|
759
|
+
*/
|
|
760
|
+
using to_ul = type_traits::value<unsigned long>;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* @brief Strongly-typed wrapper for `unsigned long long` values.
|
|
764
|
+
*
|
|
765
|
+
* @since 3.2.0
|
|
766
|
+
*/
|
|
767
|
+
using to_ull = type_traits::value<unsigned long long>;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* @brief Strongly-typed wrapper for `std::int8_t` values.
|
|
771
|
+
*
|
|
772
|
+
* @since 3.2.0
|
|
773
|
+
*/
|
|
774
|
+
using to_i8 = type_traits::value<std::int8_t>;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* @brief Strongly-typed wrapper for `std::int16_t` values.
|
|
778
|
+
*
|
|
779
|
+
* @since 3.2.0
|
|
780
|
+
*/
|
|
781
|
+
using to_i16 = type_traits::value<std::int16_t>;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @brief Strongly-typed wrapper for `std::int32_t` values.
|
|
785
|
+
*
|
|
786
|
+
* @since 3.2.0
|
|
787
|
+
*/
|
|
788
|
+
using to_i32 = type_traits::value<std::int32_t>;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* @brief Strongly-typed wrapper for `std::int64_t` values.
|
|
792
|
+
*
|
|
793
|
+
* @since 3.2.0
|
|
794
|
+
*/
|
|
795
|
+
using to_i64 = type_traits::value<std::int64_t>;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* @brief Strongly-typed wrapper for `std::uint8_t` values.
|
|
799
|
+
*
|
|
800
|
+
* @since 3.2.0
|
|
801
|
+
*/
|
|
802
|
+
using to_u8 = type_traits::value<std::uint8_t>;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* @brief Strongly-typed wrapper for `std::uint16_t` values.
|
|
806
|
+
*
|
|
807
|
+
* @since 3.2.0
|
|
808
|
+
*/
|
|
809
|
+
using to_u16 = type_traits::value<std::uint16_t>;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* @brief Strongly-typed wrapper for `std::uint32_t` values.
|
|
813
|
+
*
|
|
814
|
+
* @since 3.2.0
|
|
815
|
+
*/
|
|
816
|
+
using to_u32 = type_traits::value<std::uint32_t>;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* @brief Strongly-typed wrapper for `std::uint64_t` values.
|
|
820
|
+
*
|
|
821
|
+
* @since 3.2.0
|
|
822
|
+
*/
|
|
823
|
+
using to_u64 = type_traits::value<std::uint64_t>;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* @brief Strongly-typed wrapper for `float` values.
|
|
827
|
+
*
|
|
828
|
+
* @since 3.2.0
|
|
829
|
+
*/
|
|
830
|
+
using to_f = type_traits::value<float>;
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* @brief Strongly-typed wrapper for `double` values.
|
|
834
|
+
*
|
|
835
|
+
* @since 3.2.0
|
|
836
|
+
*/
|
|
837
|
+
using to_d = type_traits::value<double>;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* @brief Strongly-typed wrapper for `long double` values.
|
|
841
|
+
*
|
|
842
|
+
* @since 3.2.0
|
|
843
|
+
*/
|
|
844
|
+
using to_ld = type_traits::value<long double>;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* @}
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* @ingroup micro-test-plus-literals
|
|
852
|
+
* @brief Generic strongly-typed wrapper for explicit type conversion.
|
|
853
|
+
*
|
|
854
|
+
* @since 3.2.0
|
|
855
|
+
*
|
|
856
|
+
* @details
|
|
857
|
+
* The `to_t` template provides a public, strongly-typed wrapper for any type
|
|
858
|
+
* `T`, enabling explicit conversion of dynamic values and expressions to a
|
|
859
|
+
* type recognised by the µTest++ comparators and reporting mechanisms.
|
|
860
|
+
*
|
|
861
|
+
* This wrapper inherits from `type_traits::value<T>`, ensuring that the
|
|
862
|
+
* encapsulated value is treated as the specified type within the framework.
|
|
863
|
+
* It is particularly useful for enhancing type safety and clarity in test
|
|
864
|
+
* expressions, especially when working with user-defined or less common
|
|
865
|
+
* types.
|
|
866
|
+
*
|
|
867
|
+
* **Example**
|
|
868
|
+
*
|
|
869
|
+
* @code
|
|
870
|
+
* MyType obj;
|
|
871
|
+
* auto wrapped = to_t<MyType>{obj}; // Explicitly treat obj as MyType for
|
|
872
|
+
* test comparison
|
|
873
|
+
* @endcode
|
|
874
|
+
*
|
|
875
|
+
* This file is intended solely for internal use within the framework and
|
|
876
|
+
* should not be included directly by user code.
|
|
877
|
+
*
|
|
878
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
879
|
+
*/
|
|
880
|
+
template <class T>
|
|
881
|
+
struct to_t : type_traits::value<T>
|
|
882
|
+
{
|
|
883
|
+
/**
|
|
884
|
+
* @brief Constructor for the strongly-typed wrapper.
|
|
885
|
+
*
|
|
886
|
+
* @param t The value to be wrapped and explicitly converted.
|
|
887
|
+
*
|
|
888
|
+
* @details
|
|
889
|
+
* Constructs a `to_t` instance by forwarding the provided value to the
|
|
890
|
+
* base `type_traits::value<T>` wrapper.
|
|
891
|
+
*/
|
|
892
|
+
constexpr explicit to_t (const T& t) : type_traits::value<T>{ t }
|
|
893
|
+
{
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// --------------------------------------------------------------------------
|
|
898
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
899
|
+
|
|
900
|
+
#if defined(__GNUC__)
|
|
901
|
+
#pragma GCC diagnostic pop
|
|
902
|
+
#endif
|
|
903
|
+
|
|
904
|
+
// ----------------------------------------------------------------------------
|
|
905
|
+
|
|
906
|
+
#endif // __cplusplus
|
|
907
|
+
|
|
908
|
+
// ----------------------------------------------------------------------------
|
|
909
|
+
|
|
910
|
+
#endif // MICRO_TEST_PLUS_LITERALS_H_
|
|
911
|
+
|
|
912
|
+
// ----------------------------------------------------------------------------
|