@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
|
@@ -55,10 +55,6 @@
|
|
|
55
55
|
|
|
56
56
|
// ----------------------------------------------------------------------------
|
|
57
57
|
|
|
58
|
-
// #include "detail.h"
|
|
59
|
-
|
|
60
|
-
// ----------------------------------------------------------------------------
|
|
61
|
-
|
|
62
58
|
#if defined(__GNUC__)
|
|
63
59
|
#pragma GCC diagnostic push
|
|
64
60
|
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
@@ -68,6 +64,8 @@
|
|
|
68
64
|
#endif
|
|
69
65
|
#endif
|
|
70
66
|
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
71
69
|
namespace micro_os_plus::micro_test_plus
|
|
72
70
|
{
|
|
73
71
|
// --------------------------------------------------------------------------
|
|
@@ -81,7 +79,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
81
79
|
* the actual and expected values.
|
|
82
80
|
*/
|
|
83
81
|
template <class Lhs_T, class Rhs_T>
|
|
84
|
-
|
|
82
|
+
constexpr auto
|
|
85
83
|
eq (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
86
84
|
{
|
|
87
85
|
return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -96,7 +94,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
96
94
|
* addresses of objects or resources.
|
|
97
95
|
*/
|
|
98
96
|
template <class Lhs_T, class Rhs_T>
|
|
99
|
-
|
|
97
|
+
constexpr auto
|
|
100
98
|
eq (Lhs_T* lhs, Rhs_T* rhs)
|
|
101
99
|
{
|
|
102
100
|
return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
|
|
@@ -111,7 +109,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
111
109
|
* actual and expected values.
|
|
112
110
|
*/
|
|
113
111
|
template <class Lhs_T, class Rhs_T>
|
|
114
|
-
|
|
112
|
+
constexpr auto
|
|
115
113
|
ne (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
116
114
|
{
|
|
117
115
|
return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -126,7 +124,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
126
124
|
* compare the addresses of objects or resources.
|
|
127
125
|
*/
|
|
128
126
|
template <class Lhs_T, class Rhs_T>
|
|
129
|
-
|
|
127
|
+
constexpr auto
|
|
130
128
|
ne (Lhs_T* lhs, Rhs_T* rhs)
|
|
131
129
|
{
|
|
132
130
|
return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
|
|
@@ -141,7 +139,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
141
139
|
* the actual and expected values.
|
|
142
140
|
*/
|
|
143
141
|
template <class Lhs_T, class Rhs_T>
|
|
144
|
-
|
|
142
|
+
constexpr auto
|
|
145
143
|
gt (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
146
144
|
{
|
|
147
145
|
return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -156,7 +154,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
156
154
|
* assertions to compare the addresses of objects or resources.
|
|
157
155
|
*/
|
|
158
156
|
template <class Lhs_T, class Rhs_T>
|
|
159
|
-
|
|
157
|
+
constexpr auto
|
|
160
158
|
gt (Lhs_T* lhs, Rhs_T* rhs)
|
|
161
159
|
{
|
|
162
160
|
return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
|
|
@@ -171,7 +169,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
171
169
|
* and assertions to compare the actual and expected values.
|
|
172
170
|
*/
|
|
173
171
|
template <class Lhs_T, class Rhs_T>
|
|
174
|
-
|
|
172
|
+
constexpr auto
|
|
175
173
|
ge (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
176
174
|
{
|
|
177
175
|
return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -187,7 +185,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
187
185
|
* resources.
|
|
188
186
|
*/
|
|
189
187
|
template <class Lhs_T, class Rhs_T>
|
|
190
|
-
|
|
188
|
+
constexpr auto
|
|
191
189
|
ge (Lhs_T* lhs, Rhs_T* rhs)
|
|
192
190
|
{
|
|
193
191
|
return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
|
|
@@ -202,7 +200,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
202
200
|
* the actual and expected values.
|
|
203
201
|
*/
|
|
204
202
|
template <class Lhs_T, class Rhs_T>
|
|
205
|
-
|
|
203
|
+
constexpr auto
|
|
206
204
|
lt (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
207
205
|
{
|
|
208
206
|
return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -217,7 +215,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
217
215
|
* compare the addresses of objects or resources.
|
|
218
216
|
*/
|
|
219
217
|
template <class Lhs_T, class Rhs_T>
|
|
220
|
-
|
|
218
|
+
constexpr auto
|
|
221
219
|
lt (Lhs_T* lhs, Rhs_T* rhs)
|
|
222
220
|
{
|
|
223
221
|
return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
|
|
@@ -232,7 +230,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
232
230
|
* assertions to compare the actual and expected values.
|
|
233
231
|
*/
|
|
234
232
|
template <class Lhs_T, class Rhs_T>
|
|
235
|
-
|
|
233
|
+
constexpr auto
|
|
236
234
|
le (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
237
235
|
{
|
|
238
236
|
return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -248,12 +246,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
248
246
|
* resources.
|
|
249
247
|
*/
|
|
250
248
|
template <class Lhs_T, class Rhs_T>
|
|
251
|
-
|
|
249
|
+
constexpr auto
|
|
252
250
|
le (Lhs_T* lhs, Rhs_T* rhs)
|
|
253
251
|
{
|
|
254
252
|
return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
|
|
255
253
|
}
|
|
256
254
|
|
|
255
|
+
// --------------------------------------------------------------------------
|
|
256
|
+
// Logical operators.
|
|
257
|
+
|
|
257
258
|
/**
|
|
258
259
|
* @details
|
|
259
260
|
* The `_not` function template provides a generic logical negation for any
|
|
@@ -266,7 +267,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
266
267
|
* from the standard logical not operator.
|
|
267
268
|
*/
|
|
268
269
|
template <class Expr_T>
|
|
269
|
-
|
|
270
|
+
constexpr auto
|
|
270
271
|
_not (const Expr_T& expr)
|
|
271
272
|
{
|
|
272
273
|
return detail::not_<Expr_T>{ expr };
|
|
@@ -284,7 +285,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
284
285
|
* from the standard logical and operator.
|
|
285
286
|
*/
|
|
286
287
|
template <class Lhs_T, class Rhs_T>
|
|
287
|
-
|
|
288
|
+
constexpr auto
|
|
288
289
|
_and (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
289
290
|
{
|
|
290
291
|
return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
@@ -302,12 +303,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
302
303
|
* from the standard logical or operator.
|
|
303
304
|
*/
|
|
304
305
|
template <class Lhs_T, class Rhs_T>
|
|
305
|
-
|
|
306
|
+
constexpr auto
|
|
306
307
|
_or (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
307
308
|
{
|
|
308
309
|
return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
|
|
309
310
|
}
|
|
310
311
|
|
|
312
|
+
// --------------------------------------------------------------------------
|
|
313
|
+
// Utility functions.
|
|
314
|
+
|
|
311
315
|
/**
|
|
312
316
|
* @details
|
|
313
317
|
* The `mut` function template provides a safe and generic mechanism to
|
|
@@ -317,7 +321,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
317
321
|
* testing scenarios where controlled mutation of test data is required.
|
|
318
322
|
*/
|
|
319
323
|
template <class T>
|
|
320
|
-
|
|
324
|
+
constexpr auto
|
|
321
325
|
mut (const T& t) noexcept -> T&
|
|
322
326
|
{
|
|
323
327
|
return const_cast<T&> (t);
|
|
@@ -58,8 +58,6 @@
|
|
|
58
58
|
|
|
59
59
|
#include <cstdint>
|
|
60
60
|
|
|
61
|
-
// #include "type-traits.h"
|
|
62
|
-
|
|
63
61
|
// ----------------------------------------------------------------------------
|
|
64
62
|
|
|
65
63
|
#if defined(__GNUC__)
|
|
@@ -71,6 +69,8 @@
|
|
|
71
69
|
#endif
|
|
72
70
|
#endif
|
|
73
71
|
|
|
72
|
+
// ===========================================================================
|
|
73
|
+
|
|
74
74
|
namespace micro_os_plus::micro_test_plus
|
|
75
75
|
{
|
|
76
76
|
// --------------------------------------------------------------------------
|
|
@@ -90,7 +90,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
90
90
|
* and reporting mechanisms.
|
|
91
91
|
*/
|
|
92
92
|
template <char... Cs>
|
|
93
|
-
|
|
93
|
+
constexpr auto
|
|
94
94
|
operator""_i ()
|
|
95
95
|
{
|
|
96
96
|
return type_traits::integral_constant<math::num<int, Cs...> ()>{};
|
|
@@ -108,7 +108,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
108
108
|
* and reporting mechanisms.
|
|
109
109
|
*/
|
|
110
110
|
template <char... Cs>
|
|
111
|
-
|
|
111
|
+
constexpr auto
|
|
112
112
|
operator""_s ()
|
|
113
113
|
{
|
|
114
114
|
return type_traits::integral_constant<math::num<short, Cs...> ()>{};
|
|
@@ -126,7 +126,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
126
126
|
* comparators and reporting mechanisms.
|
|
127
127
|
*/
|
|
128
128
|
template <char... Cs>
|
|
129
|
-
|
|
129
|
+
constexpr auto
|
|
130
130
|
operator""_c ()
|
|
131
131
|
{
|
|
132
132
|
return type_traits::integral_constant<math::num<char, Cs...> ()>{};
|
|
@@ -144,7 +144,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
144
144
|
* and reporting mechanisms.
|
|
145
145
|
*/
|
|
146
146
|
template <char... Cs>
|
|
147
|
-
|
|
147
|
+
constexpr auto
|
|
148
148
|
operator""_sc ()
|
|
149
149
|
{
|
|
150
150
|
return type_traits::integral_constant<
|
|
@@ -163,7 +163,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
163
163
|
* and reporting mechanisms.
|
|
164
164
|
*/
|
|
165
165
|
template <char... Cs>
|
|
166
|
-
|
|
166
|
+
constexpr auto
|
|
167
167
|
operator""_l ()
|
|
168
168
|
{
|
|
169
169
|
return type_traits::integral_constant<math::num<long, Cs...> ()>{};
|
|
@@ -181,7 +181,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
181
181
|
* and reporting mechanisms.
|
|
182
182
|
*/
|
|
183
183
|
template <char... Cs>
|
|
184
|
-
|
|
184
|
+
constexpr auto
|
|
185
185
|
operator""_ll ()
|
|
186
186
|
{
|
|
187
187
|
return type_traits::integral_constant<math::num<long long, Cs...> ()>{};
|
|
@@ -199,7 +199,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
199
199
|
* and reporting mechanisms.
|
|
200
200
|
*/
|
|
201
201
|
template <char... Cs>
|
|
202
|
-
|
|
202
|
+
constexpr auto
|
|
203
203
|
operator""_u ()
|
|
204
204
|
{
|
|
205
205
|
return type_traits::integral_constant<math::num<unsigned, Cs...> ()>{};
|
|
@@ -217,7 +217,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
217
217
|
* and reporting mechanisms.
|
|
218
218
|
*/
|
|
219
219
|
template <char... Cs>
|
|
220
|
-
|
|
220
|
+
constexpr auto
|
|
221
221
|
operator""_uc ()
|
|
222
222
|
{
|
|
223
223
|
return type_traits::integral_constant<
|
|
@@ -236,7 +236,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
236
236
|
* and reporting mechanisms.
|
|
237
237
|
*/
|
|
238
238
|
template <char... Cs>
|
|
239
|
-
|
|
239
|
+
constexpr auto
|
|
240
240
|
operator""_us ()
|
|
241
241
|
{
|
|
242
242
|
return type_traits::integral_constant<
|
|
@@ -255,7 +255,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
255
255
|
* and reporting mechanisms.
|
|
256
256
|
*/
|
|
257
257
|
template <char... Cs>
|
|
258
|
-
|
|
258
|
+
constexpr auto
|
|
259
259
|
operator""_ul ()
|
|
260
260
|
{
|
|
261
261
|
return type_traits::integral_constant<
|
|
@@ -274,7 +274,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
274
274
|
* comparators and reporting mechanisms.
|
|
275
275
|
*/
|
|
276
276
|
template <char... Cs>
|
|
277
|
-
|
|
277
|
+
constexpr auto
|
|
278
278
|
operator""_ull ()
|
|
279
279
|
{
|
|
280
280
|
return type_traits::integral_constant<
|
|
@@ -293,7 +293,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
293
293
|
* and reporting mechanisms.
|
|
294
294
|
*/
|
|
295
295
|
template <char... Cs>
|
|
296
|
-
|
|
296
|
+
constexpr auto
|
|
297
297
|
operator""_i8 ()
|
|
298
298
|
{
|
|
299
299
|
return type_traits::integral_constant<
|
|
@@ -312,7 +312,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
312
312
|
* comparators and reporting mechanisms.
|
|
313
313
|
*/
|
|
314
314
|
template <char... Cs>
|
|
315
|
-
|
|
315
|
+
constexpr auto
|
|
316
316
|
operator""_i16 ()
|
|
317
317
|
{
|
|
318
318
|
return type_traits::integral_constant<
|
|
@@ -331,7 +331,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
331
331
|
* comparators and reporting mechanisms.
|
|
332
332
|
*/
|
|
333
333
|
template <char... Cs>
|
|
334
|
-
|
|
334
|
+
constexpr auto
|
|
335
335
|
operator""_i32 ()
|
|
336
336
|
{
|
|
337
337
|
return type_traits::integral_constant<
|
|
@@ -350,7 +350,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
350
350
|
* seamlessly with the µTest++ comparators and reporting mechanisms.
|
|
351
351
|
*/
|
|
352
352
|
template <char... Cs>
|
|
353
|
-
|
|
353
|
+
constexpr auto
|
|
354
354
|
operator""_i64 ()
|
|
355
355
|
{
|
|
356
356
|
return type_traits::integral_constant<
|
|
@@ -369,7 +369,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
369
369
|
* and reporting mechanisms.
|
|
370
370
|
*/
|
|
371
371
|
template <char... Cs>
|
|
372
|
-
|
|
372
|
+
constexpr auto
|
|
373
373
|
operator""_u8 ()
|
|
374
374
|
{
|
|
375
375
|
return type_traits::integral_constant<
|
|
@@ -388,7 +388,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
388
388
|
* comparators and reporting mechanisms.
|
|
389
389
|
*/
|
|
390
390
|
template <char... Cs>
|
|
391
|
-
|
|
391
|
+
constexpr auto
|
|
392
392
|
operator""_u16 ()
|
|
393
393
|
{
|
|
394
394
|
return type_traits::integral_constant<
|
|
@@ -407,7 +407,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
407
407
|
* comparators and reporting mechanisms.
|
|
408
408
|
*/
|
|
409
409
|
template <char... Cs>
|
|
410
|
-
|
|
410
|
+
constexpr auto
|
|
411
411
|
operator""_u32 ()
|
|
412
412
|
{
|
|
413
413
|
return type_traits::integral_constant<
|
|
@@ -426,7 +426,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
426
426
|
* seamlessly with the µTest++ comparators and reporting mechanisms.
|
|
427
427
|
*/
|
|
428
428
|
template <char... Cs>
|
|
429
|
-
|
|
429
|
+
constexpr auto
|
|
430
430
|
operator""_u64 ()
|
|
431
431
|
{
|
|
432
432
|
return type_traits::integral_constant<
|
|
@@ -445,7 +445,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
445
445
|
* and reporting mechanisms.
|
|
446
446
|
*/
|
|
447
447
|
template <char... Cs>
|
|
448
|
-
|
|
448
|
+
constexpr auto
|
|
449
449
|
operator""_f ()
|
|
450
450
|
{
|
|
451
451
|
return type_traits::floating_point_constant<
|
|
@@ -466,7 +466,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
466
466
|
* and reporting mechanisms.
|
|
467
467
|
*/
|
|
468
468
|
template <char... Cs>
|
|
469
|
-
|
|
469
|
+
constexpr auto
|
|
470
470
|
operator""_d ()
|
|
471
471
|
{
|
|
472
472
|
return type_traits::floating_point_constant<
|
|
@@ -487,7 +487,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
487
487
|
* comparators and reporting mechanisms.
|
|
488
488
|
*/
|
|
489
489
|
template <char... Cs>
|
|
490
|
-
|
|
490
|
+
constexpr auto
|
|
491
491
|
operator""_ld ()
|
|
492
492
|
{
|
|
493
493
|
return type_traits::floating_point_constant<
|
|
@@ -509,9 +509,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
509
509
|
*
|
|
510
510
|
* The returned type is a lightweight wrapper that behaves as a `bool` and
|
|
511
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
|
|
512
|
+
* values. This operator is intended to facilitate expressive and type-safe
|
|
515
513
|
* test conditions.
|
|
516
514
|
*/
|
|
517
515
|
constexpr auto
|
|
@@ -523,7 +521,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
523
521
|
* @details
|
|
524
522
|
* This structure inherits from `std::string_view` and a type trait base,
|
|
525
523
|
* providing a strongly-typed boolean value for use in test expressions.
|
|
526
|
-
*
|
|
527
524
|
* It defines conversion to `bool` and equality operators for comparison
|
|
528
525
|
* with other named instances and boolean values.
|
|
529
526
|
*/
|
|
@@ -543,7 +540,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
543
540
|
* Always returns `true`, representing the presence of the named
|
|
544
541
|
* literal in a test context.
|
|
545
542
|
*/
|
|
546
|
-
|
|
543
|
+
constexpr
|
|
547
544
|
operator value_type () const
|
|
548
545
|
{
|
|
549
546
|
return true;
|
|
@@ -558,7 +555,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
558
555
|
* Always returns `true`, indicating that any two named literals are
|
|
559
556
|
* considered equal in this context.
|
|
560
557
|
*/
|
|
561
|
-
|
|
558
|
+
constexpr auto
|
|
562
559
|
operator== (const named&) const
|
|
563
560
|
{
|
|
564
561
|
return true;
|
|
@@ -573,7 +570,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
573
570
|
* Returns the value of the boolean operand, allowing the named literal
|
|
574
571
|
* to be compared directly with a boolean.
|
|
575
572
|
*/
|
|
576
|
-
|
|
573
|
+
constexpr auto
|
|
577
574
|
operator== (const bool other) const
|
|
578
575
|
{
|
|
579
576
|
return other;
|
|
@@ -586,6 +583,28 @@ namespace micro_os_plus::micro_test_plus
|
|
|
586
583
|
// ------------------------------------------------------------------------
|
|
587
584
|
} // namespace literals
|
|
588
585
|
|
|
586
|
+
// ==========================================================================
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* @details
|
|
590
|
+
* Constructs an `_t` instance by forwarding the provided value to the base
|
|
591
|
+
* `type_traits::value<T>` wrapper.
|
|
592
|
+
*/
|
|
593
|
+
template <class T>
|
|
594
|
+
constexpr _t<T>::_t (const T& t) : type_traits::value<T>{ t }
|
|
595
|
+
{
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* @details
|
|
600
|
+
* Constructs a `to_t` instance by forwarding the provided value to the
|
|
601
|
+
* base `type_traits::value<T>` wrapper.
|
|
602
|
+
*/
|
|
603
|
+
template <class T>
|
|
604
|
+
constexpr to_t<T>::to_t (const T& t) : type_traits::value<T>{ t }
|
|
605
|
+
{
|
|
606
|
+
}
|
|
607
|
+
|
|
589
608
|
// --------------------------------------------------------------------------
|
|
590
609
|
} // namespace micro_os_plus::micro_test_plus
|
|
591
610
|
|
|
@@ -56,8 +56,6 @@
|
|
|
56
56
|
|
|
57
57
|
#include <cstdint>
|
|
58
58
|
|
|
59
|
-
// #include "type-traits.h"
|
|
60
|
-
|
|
61
59
|
// ----------------------------------------------------------------------------
|
|
62
60
|
|
|
63
61
|
#if defined(__GNUC__)
|
|
@@ -66,9 +64,12 @@
|
|
|
66
64
|
#if defined(__clang__)
|
|
67
65
|
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
68
66
|
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
67
|
+
#pragma clang diagnostic ignored "-Wc++20-compat"
|
|
69
68
|
#endif
|
|
70
69
|
#endif
|
|
71
70
|
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
72
73
|
namespace micro_os_plus::micro_test_plus
|
|
73
74
|
{
|
|
74
75
|
// --------------------------------------------------------------------------
|
|
@@ -92,8 +93,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
92
93
|
* less efficient, or not constexpr.
|
|
93
94
|
*/
|
|
94
95
|
template <class T>
|
|
95
|
-
|
|
96
|
-
abs (const T t) -> T
|
|
96
|
+
constexpr auto
|
|
97
|
+
abs (const T t) noexcept -> T
|
|
97
98
|
{
|
|
98
99
|
return t < T{} ? -t : t;
|
|
99
100
|
}
|
|
@@ -113,8 +114,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
113
114
|
* less efficient, or not constexpr.
|
|
114
115
|
*/
|
|
115
116
|
template <class T>
|
|
116
|
-
|
|
117
|
-
min_value (const T& lhs, const T& rhs) -> const T&
|
|
117
|
+
constexpr auto
|
|
118
|
+
min_value (const T& lhs, const T& rhs) noexcept -> const T&
|
|
118
119
|
{
|
|
119
120
|
return (rhs < lhs) ? rhs : lhs;
|
|
120
121
|
}
|
|
@@ -123,9 +124,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
123
124
|
* @details
|
|
124
125
|
* This function template provides a constexpr implementation for raising a
|
|
125
126
|
* base value to a given exponent, supporting any types that allow
|
|
126
|
-
* multiplication
|
|
127
|
+
* multiplication.
|
|
127
128
|
*
|
|
128
|
-
* The function
|
|
129
|
+
* The function iteratively multiplies the base by itself exponent times.
|
|
129
130
|
* If the exponent is zero, the function returns one (the multiplicative
|
|
130
131
|
* identity for the type).
|
|
131
132
|
*
|
|
@@ -134,11 +135,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
134
135
|
* less efficient, or not constexpr.
|
|
135
136
|
*/
|
|
136
137
|
template <class T, class Exp_T>
|
|
137
|
-
|
|
138
|
-
pow (const T base, const Exp_T exp) -> T
|
|
138
|
+
constexpr auto
|
|
139
|
+
pow (const T base, const Exp_T exp) noexcept -> T
|
|
139
140
|
{
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
T result{ 1 };
|
|
142
|
+
for (Exp_T i{}; i < exp; ++i)
|
|
143
|
+
result *= base;
|
|
144
|
+
return result;
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
/**
|
|
@@ -156,7 +159,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
156
159
|
* conversion from character sequences to integral values.
|
|
157
160
|
*/
|
|
158
161
|
template <class T, char... Cs>
|
|
159
|
-
|
|
162
|
+
consteval auto
|
|
160
163
|
num (void) -> T
|
|
161
164
|
{
|
|
162
165
|
// Assume all are digits or dot or apostrophe.
|
|
@@ -196,9 +199,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
196
199
|
* values.
|
|
197
200
|
*/
|
|
198
201
|
template <class T, char... Cs>
|
|
199
|
-
|
|
202
|
+
consteval auto
|
|
200
203
|
den (void) -> T
|
|
201
204
|
{
|
|
205
|
+
static_assert ((... || (Cs == '.')),
|
|
206
|
+
"den(): no decimal point in literal");
|
|
202
207
|
constexpr const std::array cs{ Cs... };
|
|
203
208
|
T result{};
|
|
204
209
|
auto i = 0u;
|
|
@@ -229,9 +234,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
229
234
|
* determination of decimal precision from character sequences.
|
|
230
235
|
*/
|
|
231
236
|
template <class T, char... Cs>
|
|
232
|
-
|
|
237
|
+
consteval auto
|
|
233
238
|
den_size (void) -> T
|
|
234
239
|
{
|
|
240
|
+
static_assert ((... || (Cs == '.')),
|
|
241
|
+
"den_size(): no decimal point in literal");
|
|
235
242
|
constexpr const std::array cs{ Cs... };
|
|
236
243
|
T i{};
|
|
237
244
|
#if defined(__GNUC__)
|
|
@@ -265,7 +272,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
265
272
|
* determination of decimal precision from floating-point values.
|
|
266
273
|
*/
|
|
267
274
|
template <class T, class Value_T>
|
|
268
|
-
|
|
275
|
+
constexpr auto
|
|
269
276
|
den_size (Value_T value) -> T
|
|
270
277
|
{
|
|
271
278
|
constexpr auto precision = Value_T (1e-7);
|
|
@@ -276,11 +283,10 @@ namespace micro_os_plus::micro_test_plus
|
|
|
276
283
|
value *= 10;
|
|
277
284
|
#if defined(__GNUC__)
|
|
278
285
|
#pragma GCC diagnostic push
|
|
279
|
-
#if !defined(__clang__) // GCC only
|
|
280
|
-
#pragma GCC diagnostic ignored "-Warith-conversion"
|
|
281
|
-
#endif
|
|
282
286
|
#if defined(__clang__)
|
|
283
287
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
|
|
288
|
+
#else // GCC only
|
|
289
|
+
#pragma GCC diagnostic ignored "-Warith-conversion"
|
|
284
290
|
#endif
|
|
285
291
|
#endif
|
|
286
292
|
tmp = value - T (value);
|