@micro-os-plus/micro-test-plus 3.2.2 → 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 +352 -2
- package/CMakeLists.txt +32 -30
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/{xcdl.json → config/xcdl-build.json} +6 -6
- 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 +169 -551
- package/meson.build +5 -5
- package/package.json +29 -34
- package/src/micro-test-plus.cpp +131 -35
- package/src/test-reporter.cpp +348 -6
- package/src/test-runner.cpp +69 -5
- package/src/test-suite.cpp +124 -5
- package/include/micro-os-plus/detail.h +0 -765
- package/include/micro-os-plus/inlines.h +0 -209
- package/include/micro-os-plus/literals.h +0 -512
- package/include/micro-os-plus/math.h +0 -204
- package/include/micro-os-plus/reflection.h +0 -139
- package/include/micro-os-plus/test-reporter-inlines.h +0 -230
- package/include/micro-os-plus/test-reporter.h +0 -356
- package/include/micro-os-plus/test-runner.h +0 -132
- package/include/micro-os-plus/test-suite.h +0 -306
- package/include/micro-os-plus/type-traits.h +0 -389
|
@@ -0,0 +1,604 @@
|
|
|
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 inline implementations for the µTest++ literals
|
|
21
|
+
* and type wrappers.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the inline implementations for the user-defined literal
|
|
25
|
+
* operators and type wrappers used within the µTest++ framework. It defines
|
|
26
|
+
* the logic for generating strongly-typed integral, floating-point, and
|
|
27
|
+
* boolean constants at compile time, enabling expressive and type-safe test
|
|
28
|
+
* expressions.
|
|
29
|
+
*
|
|
30
|
+
* The implemented 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
|
+
* Specialised wrappers are provided for named boolean literals, supporting
|
|
36
|
+
* enhanced expressiveness and type safety in test conditions.
|
|
37
|
+
*
|
|
38
|
+
* All definitions reside within the `micro_os_plus::micro_test_plus::literals`
|
|
39
|
+
* namespace, ensuring clear separation from user code and minimising the risk
|
|
40
|
+
* of naming conflicts.
|
|
41
|
+
*
|
|
42
|
+
* The header files are organised within the
|
|
43
|
+
* `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
|
|
44
|
+
* modular codebase.
|
|
45
|
+
*
|
|
46
|
+
* This file is intended solely for internal use within the framework and
|
|
47
|
+
* should not be included directly by user code.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
#ifndef MICRO_TEST_PLUS_LITERALS_INLINES_H_
|
|
51
|
+
#define MICRO_TEST_PLUS_LITERALS_INLINES_H_
|
|
52
|
+
|
|
53
|
+
// ----------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
#ifdef __cplusplus
|
|
56
|
+
|
|
57
|
+
// ----------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
#include <cstdint>
|
|
60
|
+
|
|
61
|
+
// #include "type-traits.h"
|
|
62
|
+
|
|
63
|
+
// ----------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
#if defined(__GNUC__)
|
|
66
|
+
#pragma GCC diagnostic push
|
|
67
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
68
|
+
#if defined(__clang__)
|
|
69
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
70
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
71
|
+
#endif
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
namespace micro_os_plus::micro_test_plus
|
|
75
|
+
{
|
|
76
|
+
// --------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
namespace literals
|
|
79
|
+
{
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @details
|
|
83
|
+
* This user-defined literal operator enables the creation of
|
|
84
|
+
* strongly-typed integral constants of type `int` from character sequences
|
|
85
|
+
* at compile time.
|
|
86
|
+
*
|
|
87
|
+
* The operator is particularly useful in test expressions, allowing
|
|
88
|
+
* constants to be suffixed with `_i` (for example, `42_i`) to produce a
|
|
89
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
90
|
+
* and reporting mechanisms.
|
|
91
|
+
*/
|
|
92
|
+
template <char... Cs>
|
|
93
|
+
[[nodiscard]] constexpr auto
|
|
94
|
+
operator""_i ()
|
|
95
|
+
{
|
|
96
|
+
return type_traits::integral_constant<math::num<int, Cs...> ()>{};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @details
|
|
101
|
+
* This user-defined literal operator enables the creation of
|
|
102
|
+
* strongly-typed integral constants of type `short` from character
|
|
103
|
+
* sequences at compile time.
|
|
104
|
+
*
|
|
105
|
+
* The operator is particularly useful in test expressions, allowing
|
|
106
|
+
* constants to be suffixed with `_s` (for example, `123_s`) to produce a
|
|
107
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
108
|
+
* and reporting mechanisms.
|
|
109
|
+
*/
|
|
110
|
+
template <char... Cs>
|
|
111
|
+
[[nodiscard]] constexpr auto
|
|
112
|
+
operator""_s ()
|
|
113
|
+
{
|
|
114
|
+
return type_traits::integral_constant<math::num<short, Cs...> ()>{};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @details
|
|
119
|
+
* This user-defined literal operator enables the creation of
|
|
120
|
+
* strongly-typed integral constants of type `char` from character
|
|
121
|
+
* sequences at compile time.
|
|
122
|
+
*
|
|
123
|
+
* The operator is particularly useful in test expressions, allowing
|
|
124
|
+
* constants to be suffixed with `_c` (for example, <tt>'A'_c</tt>) to
|
|
125
|
+
* produce a type-safe value that integrates seamlessly with the µTest++
|
|
126
|
+
* comparators and reporting mechanisms.
|
|
127
|
+
*/
|
|
128
|
+
template <char... Cs>
|
|
129
|
+
[[nodiscard]] constexpr auto
|
|
130
|
+
operator""_c ()
|
|
131
|
+
{
|
|
132
|
+
return type_traits::integral_constant<math::num<char, Cs...> ()>{};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @details
|
|
137
|
+
* This user-defined literal operator enables the creation of
|
|
138
|
+
* strongly-typed integral constants of type `signed char` from character
|
|
139
|
+
* sequences at compile time.
|
|
140
|
+
*
|
|
141
|
+
* The operator is particularly useful in test expressions, allowing
|
|
142
|
+
* constants to be suffixed with `_sc` (for example, `65_sc`) to produce a
|
|
143
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
144
|
+
* and reporting mechanisms.
|
|
145
|
+
*/
|
|
146
|
+
template <char... Cs>
|
|
147
|
+
[[nodiscard]] constexpr auto
|
|
148
|
+
operator""_sc ()
|
|
149
|
+
{
|
|
150
|
+
return type_traits::integral_constant<
|
|
151
|
+
math::num<signed char, Cs...> ()>{};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @details
|
|
156
|
+
* This user-defined literal operator enables the creation of
|
|
157
|
+
* strongly-typed integral constants of type `long` from character
|
|
158
|
+
* sequences at compile time.
|
|
159
|
+
*
|
|
160
|
+
* The operator is particularly useful in test expressions, allowing
|
|
161
|
+
* constants to be suffixed with `_l` (for example, `123_l`) to produce a
|
|
162
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
163
|
+
* and reporting mechanisms.
|
|
164
|
+
*/
|
|
165
|
+
template <char... Cs>
|
|
166
|
+
[[nodiscard]] constexpr auto
|
|
167
|
+
operator""_l ()
|
|
168
|
+
{
|
|
169
|
+
return type_traits::integral_constant<math::num<long, Cs...> ()>{};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @details
|
|
174
|
+
* This user-defined literal operator enables the creation of
|
|
175
|
+
* strongly-typed integral constants of type `long long` from character
|
|
176
|
+
* sequences at compile time.
|
|
177
|
+
*
|
|
178
|
+
* The operator is particularly useful in test expressions, allowing
|
|
179
|
+
* constants to be suffixed with `_ll` (for example, `123_ll`) to produce a
|
|
180
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
181
|
+
* and reporting mechanisms.
|
|
182
|
+
*/
|
|
183
|
+
template <char... Cs>
|
|
184
|
+
[[nodiscard]] constexpr auto
|
|
185
|
+
operator""_ll ()
|
|
186
|
+
{
|
|
187
|
+
return type_traits::integral_constant<math::num<long long, Cs...> ()>{};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @details
|
|
192
|
+
* This user-defined literal operator enables the creation of
|
|
193
|
+
* strongly-typed integral constants of type `unsigned` from character
|
|
194
|
+
* sequences at compile time.
|
|
195
|
+
*
|
|
196
|
+
* The operator is particularly useful in test expressions, allowing
|
|
197
|
+
* constants to be suffixed with `_u` (for example, `123_u`) to produce a
|
|
198
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
199
|
+
* and reporting mechanisms.
|
|
200
|
+
*/
|
|
201
|
+
template <char... Cs>
|
|
202
|
+
[[nodiscard]] constexpr auto
|
|
203
|
+
operator""_u ()
|
|
204
|
+
{
|
|
205
|
+
return type_traits::integral_constant<math::num<unsigned, Cs...> ()>{};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @details
|
|
210
|
+
* This user-defined literal operator enables the creation of
|
|
211
|
+
* strongly-typed integral constants of type `unsigned char` from character
|
|
212
|
+
* sequences at compile time.
|
|
213
|
+
*
|
|
214
|
+
* The operator is particularly useful in test expressions, allowing
|
|
215
|
+
* constants to be suffixed with `_uc` (for example, `65_uc`) to produce a
|
|
216
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
217
|
+
* and reporting mechanisms.
|
|
218
|
+
*/
|
|
219
|
+
template <char... Cs>
|
|
220
|
+
[[nodiscard]] constexpr auto
|
|
221
|
+
operator""_uc ()
|
|
222
|
+
{
|
|
223
|
+
return type_traits::integral_constant<
|
|
224
|
+
math::num<unsigned char, Cs...> ()>{};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @details
|
|
229
|
+
* This user-defined literal operator enables the creation of
|
|
230
|
+
* strongly-typed integral constants of type `unsigned short` from
|
|
231
|
+
* character sequences at compile time.
|
|
232
|
+
*
|
|
233
|
+
* The operator is particularly useful in test expressions, allowing
|
|
234
|
+
* constants to be suffixed with `_us` (for example, `123_us`) to produce a
|
|
235
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
236
|
+
* and reporting mechanisms.
|
|
237
|
+
*/
|
|
238
|
+
template <char... Cs>
|
|
239
|
+
[[nodiscard]] constexpr auto
|
|
240
|
+
operator""_us ()
|
|
241
|
+
{
|
|
242
|
+
return type_traits::integral_constant<
|
|
243
|
+
math::num<unsigned short, Cs...> ()>{};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @details
|
|
248
|
+
* This user-defined literal operator enables the creation of
|
|
249
|
+
* strongly-typed integral constants of type `unsigned long` from character
|
|
250
|
+
* sequences at compile time.
|
|
251
|
+
*
|
|
252
|
+
* The operator is particularly useful in test expressions, allowing
|
|
253
|
+
* constants to be suffixed with `_ul` (for example, `123_ul`) to produce a
|
|
254
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
255
|
+
* and reporting mechanisms.
|
|
256
|
+
*/
|
|
257
|
+
template <char... Cs>
|
|
258
|
+
[[nodiscard]] constexpr auto
|
|
259
|
+
operator""_ul ()
|
|
260
|
+
{
|
|
261
|
+
return type_traits::integral_constant<
|
|
262
|
+
math::num<unsigned long, Cs...> ()>{};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @details
|
|
267
|
+
* This user-defined literal operator enables the creation of
|
|
268
|
+
* strongly-typed integral constants of type `unsigned long long` from
|
|
269
|
+
* character sequences at compile time.
|
|
270
|
+
*
|
|
271
|
+
* The operator is particularly useful in test expressions, allowing
|
|
272
|
+
* constants to be suffixed with `_ull` (for example, `123_ull`) to produce
|
|
273
|
+
* a type-safe value that integrates seamlessly with the µTest++
|
|
274
|
+
* comparators and reporting mechanisms.
|
|
275
|
+
*/
|
|
276
|
+
template <char... Cs>
|
|
277
|
+
[[nodiscard]] constexpr auto
|
|
278
|
+
operator""_ull ()
|
|
279
|
+
{
|
|
280
|
+
return type_traits::integral_constant<
|
|
281
|
+
math::num<unsigned long long, Cs...> ()>{};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @details
|
|
286
|
+
* This user-defined literal operator enables the creation of
|
|
287
|
+
* strongly-typed integral constants of type `int8_t` from character
|
|
288
|
+
* sequences at compile time.
|
|
289
|
+
*
|
|
290
|
+
* The operator is particularly useful in test expressions, allowing
|
|
291
|
+
* constants to be suffixed with `_i8` (for example, `127_i8`) to produce a
|
|
292
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
293
|
+
* and reporting mechanisms.
|
|
294
|
+
*/
|
|
295
|
+
template <char... Cs>
|
|
296
|
+
[[nodiscard]] constexpr auto
|
|
297
|
+
operator""_i8 ()
|
|
298
|
+
{
|
|
299
|
+
return type_traits::integral_constant<
|
|
300
|
+
math::num<std::int8_t, Cs...> ()>{};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @details
|
|
305
|
+
* This user-defined literal operator enables the creation of
|
|
306
|
+
* strongly-typed integral constants of type `int16_t` from character
|
|
307
|
+
* sequences at compile time.
|
|
308
|
+
*
|
|
309
|
+
* The operator is particularly useful in test expressions, allowing
|
|
310
|
+
* constants to be suffixed with `_i16` (for example, `32767_i16`) to
|
|
311
|
+
* produce a type-safe value that integrates seamlessly with the µTest++
|
|
312
|
+
* comparators and reporting mechanisms.
|
|
313
|
+
*/
|
|
314
|
+
template <char... Cs>
|
|
315
|
+
[[nodiscard]] constexpr auto
|
|
316
|
+
operator""_i16 ()
|
|
317
|
+
{
|
|
318
|
+
return type_traits::integral_constant<
|
|
319
|
+
math::num<std::int16_t, Cs...> ()>{};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @details
|
|
324
|
+
* This user-defined literal operator enables the creation of
|
|
325
|
+
* strongly-typed integral constants of type `int32_t` from character
|
|
326
|
+
* sequences at compile time.
|
|
327
|
+
*
|
|
328
|
+
* The operator is particularly useful in test expressions, allowing
|
|
329
|
+
* constants to be suffixed with `_i32` (for example, `2147483647_i32`) to
|
|
330
|
+
* produce a type-safe value that integrates seamlessly with the µTest++
|
|
331
|
+
* comparators and reporting mechanisms.
|
|
332
|
+
*/
|
|
333
|
+
template <char... Cs>
|
|
334
|
+
[[nodiscard]] constexpr auto
|
|
335
|
+
operator""_i32 ()
|
|
336
|
+
{
|
|
337
|
+
return type_traits::integral_constant<
|
|
338
|
+
math::num<std::int32_t, Cs...> ()>{};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @details
|
|
343
|
+
* This user-defined literal operator enables the creation of
|
|
344
|
+
* strongly-typed integral constants of type `int64_t` from character
|
|
345
|
+
* sequences at compile time.
|
|
346
|
+
*
|
|
347
|
+
* The operator is particularly useful in test expressions, allowing
|
|
348
|
+
* constants to be suffixed with `_i64` (for example,
|
|
349
|
+
* `9223372036854775807_i64`) to produce a type-safe value that integrates
|
|
350
|
+
* seamlessly with the µTest++ comparators and reporting mechanisms.
|
|
351
|
+
*/
|
|
352
|
+
template <char... Cs>
|
|
353
|
+
[[nodiscard]] constexpr auto
|
|
354
|
+
operator""_i64 ()
|
|
355
|
+
{
|
|
356
|
+
return type_traits::integral_constant<
|
|
357
|
+
math::num<std::int64_t, Cs...> ()>{};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @details
|
|
362
|
+
* This user-defined literal operator enables the creation of
|
|
363
|
+
* strongly-typed integral constants of type `uint8_t` from character
|
|
364
|
+
* sequences at compile time.
|
|
365
|
+
*
|
|
366
|
+
* The operator is particularly useful in test expressions, allowing
|
|
367
|
+
* constants to be suffixed with `_u8` (for example, `255_u8`) to produce a
|
|
368
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
369
|
+
* and reporting mechanisms.
|
|
370
|
+
*/
|
|
371
|
+
template <char... Cs>
|
|
372
|
+
[[nodiscard]] constexpr auto
|
|
373
|
+
operator""_u8 ()
|
|
374
|
+
{
|
|
375
|
+
return type_traits::integral_constant<
|
|
376
|
+
math::num<std::uint8_t, Cs...> ()>{};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* @details
|
|
381
|
+
* This user-defined literal operator enables the creation of
|
|
382
|
+
* strongly-typed integral constants of type `uint16_t` from character
|
|
383
|
+
* sequences at compile time.
|
|
384
|
+
*
|
|
385
|
+
* The operator is particularly useful in test expressions, allowing
|
|
386
|
+
* constants to be suffixed with `_u16` (for example, `65535_u16`) to
|
|
387
|
+
* produce a type-safe value that integrates seamlessly with the µTest++
|
|
388
|
+
* comparators and reporting mechanisms.
|
|
389
|
+
*/
|
|
390
|
+
template <char... Cs>
|
|
391
|
+
[[nodiscard]] constexpr auto
|
|
392
|
+
operator""_u16 ()
|
|
393
|
+
{
|
|
394
|
+
return type_traits::integral_constant<
|
|
395
|
+
math::num<std::uint16_t, Cs...> ()>{};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @details
|
|
400
|
+
* This user-defined literal operator enables the creation of
|
|
401
|
+
* strongly-typed integral constants of type `uint32_t` from character
|
|
402
|
+
* sequences at compile time.
|
|
403
|
+
*
|
|
404
|
+
* The operator is particularly useful in test expressions, allowing
|
|
405
|
+
* constants to be suffixed with `_u32` (for example, `4294967295_u32`) to
|
|
406
|
+
* produce a type-safe value that integrates seamlessly with the µTest++
|
|
407
|
+
* comparators and reporting mechanisms.
|
|
408
|
+
*/
|
|
409
|
+
template <char... Cs>
|
|
410
|
+
[[nodiscard]] constexpr auto
|
|
411
|
+
operator""_u32 ()
|
|
412
|
+
{
|
|
413
|
+
return type_traits::integral_constant<
|
|
414
|
+
math::num<std::uint32_t, Cs...> ()>{};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @details
|
|
419
|
+
* This user-defined literal operator enables the creation of
|
|
420
|
+
* strongly-typed integral constants of type `uint64_t` from character
|
|
421
|
+
* sequences at compile time.
|
|
422
|
+
*
|
|
423
|
+
* The operator is particularly useful in test expressions, allowing
|
|
424
|
+
* constants to be suffixed with `_u64` (for example,
|
|
425
|
+
* `18446744073709551615_u64`) to produce a type-safe value that integrates
|
|
426
|
+
* seamlessly with the µTest++ comparators and reporting mechanisms.
|
|
427
|
+
*/
|
|
428
|
+
template <char... Cs>
|
|
429
|
+
[[nodiscard]] constexpr auto
|
|
430
|
+
operator""_u64 ()
|
|
431
|
+
{
|
|
432
|
+
return type_traits::integral_constant<
|
|
433
|
+
math::num<std::uint64_t, Cs...> ()>{};
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @details
|
|
438
|
+
* This user-defined literal operator enables the creation of
|
|
439
|
+
* strongly-typed floating-point constants of type `float` from character
|
|
440
|
+
* sequences at compile time.
|
|
441
|
+
*
|
|
442
|
+
* The operator is particularly useful in test expressions, allowing
|
|
443
|
+
* constants to be suffixed with `_f` (for example, `3.14_f`) to produce a
|
|
444
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
445
|
+
* and reporting mechanisms.
|
|
446
|
+
*/
|
|
447
|
+
template <char... Cs>
|
|
448
|
+
[[nodiscard]] constexpr auto
|
|
449
|
+
operator""_f ()
|
|
450
|
+
{
|
|
451
|
+
return type_traits::floating_point_constant<
|
|
452
|
+
float, math::num<unsigned long, Cs...> (),
|
|
453
|
+
math::den<unsigned long, Cs...> (),
|
|
454
|
+
math::den_size<unsigned long, Cs...> ()>{};
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* @details
|
|
459
|
+
* This user-defined literal operator enables the creation of
|
|
460
|
+
* strongly-typed floating-point constants of type `double` from character
|
|
461
|
+
* sequences at compile time.
|
|
462
|
+
*
|
|
463
|
+
* The operator is particularly useful in test expressions, allowing
|
|
464
|
+
* constants to be suffixed with `_d` (for example, `2.718_d`) to produce a
|
|
465
|
+
* type-safe value that integrates seamlessly with the µTest++ comparators
|
|
466
|
+
* and reporting mechanisms.
|
|
467
|
+
*/
|
|
468
|
+
template <char... Cs>
|
|
469
|
+
[[nodiscard]] constexpr auto
|
|
470
|
+
operator""_d ()
|
|
471
|
+
{
|
|
472
|
+
return type_traits::floating_point_constant<
|
|
473
|
+
double, math::num<unsigned long, Cs...> (),
|
|
474
|
+
math::den<unsigned long, Cs...> (),
|
|
475
|
+
math::den_size<unsigned long, Cs...> ()>{};
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* @details
|
|
480
|
+
* This user-defined literal operator enables the creation of
|
|
481
|
+
* strongly-typed floating-point constants of type `long double` from
|
|
482
|
+
* character sequences at compile time.
|
|
483
|
+
*
|
|
484
|
+
* The operator is particularly useful in test expressions, allowing
|
|
485
|
+
* constants to be suffixed with `_ld` (for example, `1.618_ld`) to produce
|
|
486
|
+
* a type-safe value that integrates seamlessly with the µTest++
|
|
487
|
+
* comparators and reporting mechanisms.
|
|
488
|
+
*/
|
|
489
|
+
template <char... Cs>
|
|
490
|
+
[[nodiscard]] constexpr auto
|
|
491
|
+
operator""_ld ()
|
|
492
|
+
{
|
|
493
|
+
return type_traits::floating_point_constant<
|
|
494
|
+
long double, math::num<unsigned long long, Cs...> (),
|
|
495
|
+
math::den<unsigned long long, Cs...> (),
|
|
496
|
+
math::den_size<unsigned long long, Cs...> ()>{};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* @details
|
|
501
|
+
* This user-defined literal operator enables the creation of
|
|
502
|
+
* strongly-typed boolean constants from character sequences at compile
|
|
503
|
+
* time.
|
|
504
|
+
*
|
|
505
|
+
* The operator is particularly useful in test expressions, allowing string
|
|
506
|
+
* literals to be suffixed with `_b` (for example, `"feature_enabled"_b`)
|
|
507
|
+
* to produce a type-safe value that integrates seamlessly with the µTest++
|
|
508
|
+
* comparators and reporting mechanisms.
|
|
509
|
+
*
|
|
510
|
+
* The returned type is a lightweight wrapper that behaves as a `bool` and
|
|
511
|
+
* supports equality comparison with both other named instances and boolean
|
|
512
|
+
* values.
|
|
513
|
+
*
|
|
514
|
+
* @note This operator is intended to facilitate expressive and type-safe
|
|
515
|
+
* test conditions.
|
|
516
|
+
*/
|
|
517
|
+
constexpr auto
|
|
518
|
+
operator""_b (const char* name, decltype (sizeof ("")) size)
|
|
519
|
+
{
|
|
520
|
+
/**
|
|
521
|
+
* @brief Wrapper type for named boolean literals.
|
|
522
|
+
*
|
|
523
|
+
* @details
|
|
524
|
+
* This structure inherits from `std::string_view` and a type trait base,
|
|
525
|
+
* providing a strongly-typed boolean value for use in test expressions.
|
|
526
|
+
*
|
|
527
|
+
* It defines conversion to `bool` and equality operators for comparison
|
|
528
|
+
* with other named instances and boolean values.
|
|
529
|
+
*/
|
|
530
|
+
struct named : std::string_view, type_traits::op
|
|
531
|
+
{
|
|
532
|
+
/**
|
|
533
|
+
* @brief The underlying value type.
|
|
534
|
+
*/
|
|
535
|
+
using value_type = bool;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* @brief Conversion operator to `bool`.
|
|
539
|
+
*
|
|
540
|
+
* @return `true`
|
|
541
|
+
*
|
|
542
|
+
* @details
|
|
543
|
+
* Always returns `true`, representing the presence of the named
|
|
544
|
+
* literal in a test context.
|
|
545
|
+
*/
|
|
546
|
+
[[nodiscard]] constexpr
|
|
547
|
+
operator value_type () const
|
|
548
|
+
{
|
|
549
|
+
return true;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* @brief Equality comparison with another named instance.
|
|
554
|
+
*
|
|
555
|
+
* @return `true`
|
|
556
|
+
*
|
|
557
|
+
* @details
|
|
558
|
+
* Always returns `true`, indicating that any two named literals are
|
|
559
|
+
* considered equal in this context.
|
|
560
|
+
*/
|
|
561
|
+
[[nodiscard]] constexpr auto
|
|
562
|
+
operator== (const named&) const
|
|
563
|
+
{
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* @brief Equality comparison with a boolean value.
|
|
569
|
+
*
|
|
570
|
+
* @return The value of @p other.
|
|
571
|
+
*
|
|
572
|
+
* @details
|
|
573
|
+
* Returns the value of the boolean operand, allowing the named literal
|
|
574
|
+
* to be compared directly with a boolean.
|
|
575
|
+
*/
|
|
576
|
+
[[nodiscard]] constexpr auto
|
|
577
|
+
operator== (const bool other) const
|
|
578
|
+
{
|
|
579
|
+
return other;
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
return named{ { name, size }, {} };
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// ------------------------------------------------------------------------
|
|
587
|
+
} // namespace literals
|
|
588
|
+
|
|
589
|
+
// --------------------------------------------------------------------------
|
|
590
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
591
|
+
|
|
592
|
+
#if defined(__GNUC__)
|
|
593
|
+
#pragma GCC diagnostic pop
|
|
594
|
+
#endif
|
|
595
|
+
|
|
596
|
+
// ----------------------------------------------------------------------------
|
|
597
|
+
|
|
598
|
+
#endif // __cplusplus
|
|
599
|
+
|
|
600
|
+
// ----------------------------------------------------------------------------
|
|
601
|
+
|
|
602
|
+
#endif // MICRO_TEST_PLUS_LITERALS_INLINES_H_
|
|
603
|
+
|
|
604
|
+
// ----------------------------------------------------------------------------
|