@micro-os-plus/micro-test-plus 3.2.2 → 3.3.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.
Files changed (45) hide show
  1. package/.cmake-format.yaml +11 -0
  2. package/CHANGELOG.md +417 -2
  3. package/CMakeLists.txt +33 -30
  4. package/LICENSE +1 -1
  5. package/README.md +1 -1
  6. package/{xcdl.json → config/xcdl-build.json} +6 -6
  7. package/include/micro-os-plus/micro-test-plus/detail.h +1908 -0
  8. package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
  9. package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
  10. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
  11. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
  12. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
  15. package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +476 -0
  16. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
  17. package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
  18. package/include/micro-os-plus/micro-test-plus/math.h +217 -0
  19. package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
  20. package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
  21. package/include/micro-os-plus/micro-test-plus/test-reporter-basic.h +289 -0
  22. package/include/micro-os-plus/micro-test-plus/test-reporter-tap.h +281 -0
  23. package/include/micro-os-plus/micro-test-plus/test-reporter.h +846 -0
  24. package/include/micro-os-plus/micro-test-plus/test-runner.h +281 -0
  25. package/include/micro-os-plus/micro-test-plus/test-suite.h +492 -0
  26. package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
  27. package/include/micro-os-plus/micro-test-plus.h +172 -552
  28. package/meson.build +7 -5
  29. package/package.json +29 -34
  30. package/src/micro-test-plus.cpp +134 -37
  31. package/src/test-reporter-basic.cpp +466 -0
  32. package/src/test-reporter-tap.cpp +530 -0
  33. package/src/test-reporter.cpp +207 -240
  34. package/src/test-runner.cpp +135 -23
  35. package/src/test-suite.cpp +182 -10
  36. package/include/micro-os-plus/detail.h +0 -765
  37. package/include/micro-os-plus/inlines.h +0 -209
  38. package/include/micro-os-plus/literals.h +0 -512
  39. package/include/micro-os-plus/math.h +0 -204
  40. package/include/micro-os-plus/reflection.h +0 -139
  41. package/include/micro-os-plus/test-reporter-inlines.h +0 -230
  42. package/include/micro-os-plus/test-reporter.h +0 -356
  43. package/include/micro-os-plus/test-runner.h +0 -132
  44. package/include/micro-os-plus/test-suite.h +0 -306
  45. package/include/micro-os-plus/type-traits.h +0 -389
@@ -1,209 +0,0 @@
1
- /*
2
- * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
- * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any 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
9
- * be 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
- #ifndef MICRO_TEST_PLUS_INLINES_H_
17
- #define MICRO_TEST_PLUS_INLINES_H_
18
-
19
- // ----------------------------------------------------------------------------
20
-
21
- #ifdef __cplusplus
22
-
23
- // ----------------------------------------------------------------------------
24
-
25
- #if defined(__GNUC__)
26
- #pragma GCC diagnostic push
27
- #pragma GCC diagnostic ignored "-Waggregate-return"
28
- #pragma GCC diagnostic ignored "-Wpadded"
29
- #if defined(__clang__)
30
- #pragma clang diagnostic ignored "-Wc++98-compat"
31
- #pragma clang diagnostic ignored "-Wc++98-c++11-c++14-c++17-compat-pedantic"
32
- #endif
33
- #endif
34
-
35
- namespace micro_os_plus::micro_test_plus
36
- {
37
- // --------------------------------------------------------------------------
38
-
39
- template <typename Callable_T, typename... Args_T>
40
- test_suite::test_suite (const char* name, Callable_T&& callable,
41
- Args_T&&... arguments)
42
- : test_suite_base{ name },
43
- callable_{ std::bind (callable, arguments...) }
44
- {
45
- #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
46
- printf ("%s\n", __PRETTY_FUNCTION__);
47
- #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
48
-
49
- runner.register_test_suite (this);
50
- }
51
-
52
- // --------------------------------------------------------------------------
53
-
54
- #if defined(__clang__)
55
- #pragma clang diagnostic push
56
- #pragma clang diagnostic ignored "-Wdocumentation"
57
- #endif
58
- /**
59
- * @details
60
- * A test case is a sequence of test conditions (or simply tests,
61
- * or checks), which are expectations/assumptions, i.e. conditions
62
- * expected to be true.
63
- *
64
- * Tests are based on logical expressions, which usually compute
65
- * a result and compare it to an expected value.
66
- * For C++ projects, it is also possible to check if, while
67
- * evaluating an expression, exceptions are thrown or not.
68
- * Each test either succeeds or fails.
69
- * For expectations, the runner keeps counts of successful
70
- * and failed tests.
71
- *
72
- * A test case has a name, a function which performs the checks, and
73
- * possibly arguments.
74
- *
75
- * The `test_case` implementation invokes the function with
76
- * the provided arguments, and reports the results.
77
- *
78
- * @par Example
79
- * ```cpp
80
- * namespace mt = micro_os_plus::micro_test_plus;
81
- *
82
- * mt::test_case ("Check answer with comparator", [] {
83
- * mt::expect (mt::eq (compute_answer (), 42)) << "answer is 42";
84
- * });
85
- * ```
86
- */
87
- #if defined(__clang__)
88
- #pragma clang diagnostic pop
89
- #endif
90
- template <typename Callable_T, typename... Args_T>
91
- void
92
- test_case (const char* name, Callable_T&& callable, Args_T&&... arguments)
93
- {
94
- #if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
95
- printf ("%s\n", __PRETTY_FUNCTION__);
96
- #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
97
-
98
- current_test_suite->begin_test_case (name);
99
- std::invoke (std::forward<Callable_T> (callable),
100
- std::forward<Args_T> (arguments)...);
101
- current_test_suite->end_test_case ();
102
- }
103
-
104
- // --------------------------------------------------------------------------
105
- namespace detail
106
- {
107
- // ------------------------------------------------------------------------
108
-
109
- template <class T>
110
- auto&
111
- deferred_reporter_base::operator<< (const T& msg)
112
- {
113
- if constexpr (std::is_arithmetic_v<T>)
114
- {
115
- message_.append (std::to_string (msg));
116
- }
117
- else
118
- {
119
- message_.append (msg);
120
- }
121
- return *this;
122
- }
123
-
124
- // ------------------------------------------------------------------------
125
-
126
- template <class Expr_T>
127
- constexpr deferred_reporter<Expr_T>::deferred_reporter (
128
- const Expr_T& expr, bool abort,
129
- const reflection::source_location& location)
130
- : deferred_reporter_base{ static_cast<bool> (expr), location },
131
- expr_{ expr }
132
- {
133
- #if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
134
- printf ("%s\n", __PRETTY_FUNCTION__);
135
- #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
136
- abort_ = abort;
137
- }
138
-
139
- template <class Expr_T>
140
- deferred_reporter<Expr_T>::~deferred_reporter ()
141
- {
142
- if (value_)
143
- {
144
- reporter.pass (expr_, message_);
145
- }
146
- else
147
- {
148
- reporter.fail (expr_, abort_, message_, location_);
149
- }
150
- }
151
-
152
- // ------------------------------------------------------------------------
153
- } // namespace detail
154
-
155
- // --------------------------------------------------------------------------
156
- namespace utility
157
- {
158
- /**
159
- * @details
160
- * For tests handling strings, this function template allows
161
- * to split a string into a vector of substrings, using a delimiter.
162
- *
163
- * @par Example
164
- * ```cpp
165
- * namespace mt = micro_os_plus::micro_test_plus;
166
- *
167
- * mt::expect (std::vector<std::string_view>{ "a", "b" }
168
- * == mt::utility::split<std::string_view> ("a.b", "."))
169
- * << "a.b splits into [a,b]";
170
- * ```
171
- */
172
- template <class T = std::string_view, class Delim_T>
173
- [[nodiscard]] auto
174
- split (T input, Delim_T delim) -> std::vector<T>
175
- {
176
- std::vector<T> output{};
177
- std::size_t first{};
178
- while (first < std::size (input))
179
- {
180
- const auto second = input.find_first_of (delim, first);
181
- if (first != second)
182
- {
183
- output.emplace_back (input.substr (first, second - first));
184
- }
185
- if (second == T::npos)
186
- {
187
- break;
188
- }
189
- first = second + 1;
190
- }
191
- return output;
192
- }
193
- } // namespace utility
194
-
195
- } // namespace micro_os_plus::micro_test_plus
196
-
197
- #if defined(__GNUC__)
198
- #pragma GCC diagnostic pop
199
- #endif
200
-
201
- // ----------------------------------------------------------------------------
202
-
203
- #endif // __cplusplus
204
-
205
- // ----------------------------------------------------------------------------
206
-
207
- #endif // MICRO_TEST_PLUS_INLINES_H_
208
-
209
- // ----------------------------------------------------------------------------
@@ -1,512 +0,0 @@
1
- /*
2
- * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
- * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any 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
9
- * be 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
- #ifndef MICRO_TEST_PLUS_LITERALS_H_
17
- #define MICRO_TEST_PLUS_LITERALS_H_
18
-
19
- // ----------------------------------------------------------------------------
20
-
21
- #ifdef __cplusplus
22
-
23
- // ----------------------------------------------------------------------------
24
-
25
- #include "type-traits.h"
26
- #include "math.h"
27
- #include <cstdint>
28
-
29
- // ----------------------------------------------------------------------------
30
-
31
- #if defined(__GNUC__)
32
- #pragma GCC diagnostic push
33
- #pragma GCC diagnostic ignored "-Waggregate-return"
34
- #if defined(__clang__)
35
- #pragma clang diagnostic ignored "-Wc++98-compat"
36
- #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
37
- #endif
38
- #endif
39
-
40
- namespace micro_os_plus::micro_test_plus
41
- {
42
- // --------------------------------------------------------------------------
43
-
44
- /**
45
- * @brief User Defined Literals (UDL). Use them to suffix
46
- * constants and obtain specific explicit types, like `1_i`.
47
- */
48
- namespace literals
49
- {
50
- /**
51
- * @ingroup micro-test-plus-literals
52
- * @brief Operator to convert to `int`.
53
- */
54
- template <char... Cs>
55
- [[nodiscard]] constexpr auto
56
- operator""_i ()
57
- {
58
- return type_traits::integral_constant<math::num<int, Cs...> ()>{};
59
- }
60
-
61
- /**
62
- * @ingroup micro-test-plus-literals
63
- * @brief Operator to convert to `short`.
64
- */
65
- template <char... Cs>
66
- [[nodiscard]] constexpr auto
67
- operator""_s ()
68
- {
69
- return type_traits::integral_constant<math::num<short, Cs...> ()>{};
70
- }
71
-
72
- /**
73
- * @ingroup micro-test-plus-literals
74
- * @brief Operator to convert to `char`.
75
- */
76
- template <char... Cs>
77
- [[nodiscard]] constexpr auto
78
- operator""_c ()
79
- {
80
- return type_traits::integral_constant<math::num<char, Cs...> ()>{};
81
- }
82
-
83
- /**
84
- * @ingroup micro-test-plus-literals
85
- * @brief Operator to convert to `signed char`.
86
- */
87
- template <char... Cs>
88
- [[nodiscard]] constexpr auto
89
- operator""_sc ()
90
- {
91
- return type_traits::integral_constant<
92
- math::num<signed char, Cs...> ()>{};
93
- }
94
-
95
- /**
96
- * @ingroup micro-test-plus-literals
97
- * @brief Operator to convert to `long`.
98
- */
99
- template <char... Cs>
100
- [[nodiscard]] constexpr auto
101
- operator""_l ()
102
- {
103
- return type_traits::integral_constant<math::num<long, Cs...> ()>{};
104
- }
105
-
106
- /**
107
- * @ingroup micro-test-plus-literals
108
- * @brief Operator to convert to `long long`.
109
- */
110
- template <char... Cs>
111
- [[nodiscard]] constexpr auto
112
- operator""_ll ()
113
- {
114
- return type_traits::integral_constant<math::num<long long, Cs...> ()>{};
115
- }
116
-
117
- /**
118
- * @ingroup micro-test-plus-literals
119
- * @brief Operator to convert to `unsigned`.
120
- */
121
- template <char... Cs>
122
- [[nodiscard]] constexpr auto
123
- operator""_u ()
124
- {
125
- return type_traits::integral_constant<math::num<unsigned, Cs...> ()>{};
126
- }
127
-
128
- /**
129
- * @ingroup micro-test-plus-literals
130
- * @brief Operator to convert to `unsigned char`.
131
- */
132
- template <char... Cs>
133
- [[nodiscard]] constexpr auto
134
- operator""_uc ()
135
- {
136
- return type_traits::integral_constant<
137
- math::num<unsigned char, Cs...> ()>{};
138
- }
139
-
140
- /**
141
- * @ingroup micro-test-plus-literals
142
- * @brief Operator to convert to `unsigned short`.
143
- */
144
- template <char... Cs>
145
- [[nodiscard]] constexpr auto
146
- operator""_us ()
147
- {
148
- return type_traits::integral_constant<
149
- math::num<unsigned short, Cs...> ()>{};
150
- }
151
-
152
- /**
153
- * @ingroup micro-test-plus-literals
154
- * @brief Operator to convert to `unsigned long`.
155
- */
156
- template <char... Cs>
157
- [[nodiscard]] constexpr auto
158
- operator""_ul ()
159
- {
160
- return type_traits::integral_constant<
161
- math::num<unsigned long, Cs...> ()>{};
162
- }
163
-
164
- /**
165
- * @ingroup micro-test-plus-literals
166
- * @brief Operator to convert to `unsigned long long`.
167
- */
168
- template <char... Cs>
169
- [[nodiscard]] constexpr auto
170
- operator""_ull ()
171
- {
172
- return type_traits::integral_constant<
173
- math::num<unsigned long long, Cs...> ()>{};
174
- }
175
-
176
- /**
177
- * @ingroup micro-test-plus-literals
178
- * @brief Operator to convert to `int8_t`.
179
- */
180
- template <char... Cs>
181
- [[nodiscard]] constexpr auto
182
- operator""_i8 ()
183
- {
184
- return type_traits::integral_constant<
185
- math::num<std::int8_t, Cs...> ()>{};
186
- }
187
-
188
- /**
189
- * @ingroup micro-test-plus-literals
190
- * @brief Operator to convert to `int16_t`.
191
- */
192
- template <char... Cs>
193
- [[nodiscard]] constexpr auto
194
- operator""_i16 ()
195
- {
196
- return type_traits::integral_constant<
197
- math::num<std::int16_t, Cs...> ()>{};
198
- }
199
-
200
- /**
201
- * @ingroup micro-test-plus-literals
202
- * @brief Operator to convert to `int32_t`.
203
- */
204
- template <char... Cs>
205
- [[nodiscard]] constexpr auto
206
- operator""_i32 ()
207
- {
208
- return type_traits::integral_constant<
209
- math::num<std::int32_t, Cs...> ()>{};
210
- }
211
-
212
- /**
213
- * @ingroup micro-test-plus-literals
214
- * @brief Operator to convert to `int64_t`.
215
- */
216
- template <char... Cs>
217
- [[nodiscard]] constexpr auto
218
- operator""_i64 ()
219
- {
220
- return type_traits::integral_constant<
221
- math::num<std::int64_t, Cs...> ()>{};
222
- }
223
-
224
- /**
225
- * @ingroup micro-test-plus-literals
226
- * @brief Operator to convert to `uint8_t`.
227
- */
228
- template <char... Cs>
229
- [[nodiscard]] constexpr auto
230
- operator""_u8 ()
231
- {
232
- return type_traits::integral_constant<
233
- math::num<std::uint8_t, Cs...> ()>{};
234
- }
235
-
236
- /**
237
- * @ingroup micro-test-plus-literals
238
- * @brief Operator to convert to `uint16_t`.
239
- */
240
- template <char... Cs>
241
- [[nodiscard]] constexpr auto
242
- operator""_u16 ()
243
- {
244
- return type_traits::integral_constant<
245
- math::num<std::uint16_t, Cs...> ()>{};
246
- }
247
-
248
- /**
249
- * @ingroup micro-test-plus-literals
250
- * @brief Operator to convert to `uint32_t`.
251
- */
252
- template <char... Cs>
253
- [[nodiscard]] constexpr auto
254
- operator""_u32 ()
255
- {
256
- return type_traits::integral_constant<
257
- math::num<std::uint32_t, Cs...> ()>{};
258
- }
259
-
260
- /**
261
- * @ingroup micro-test-plus-literals
262
- * @brief Operator to convert to `uint64_t`.
263
- */
264
- template <char... Cs>
265
- [[nodiscard]] constexpr auto
266
- operator""_u64 ()
267
- {
268
- return type_traits::integral_constant<
269
- math::num<std::uint64_t, Cs...> ()>{};
270
- }
271
-
272
- /**
273
- * @ingroup micro-test-plus-literals
274
- * @brief Operator to convert to `float`.
275
- */
276
- template <char... Cs>
277
- [[nodiscard]] constexpr auto
278
- operator""_f ()
279
- {
280
- return type_traits::floating_point_constant<
281
- float, math::num<unsigned long, Cs...> (),
282
- math::den<unsigned long, Cs...> (),
283
- math::den_size<unsigned long, Cs...> ()>{};
284
- }
285
-
286
- /**
287
- * @ingroup micro-test-plus-literals
288
- * @brief Operator to convert to `double`.
289
- */
290
- template <char... Cs>
291
- [[nodiscard]] constexpr auto
292
- operator""_d ()
293
- {
294
- return type_traits::floating_point_constant<
295
- double, math::num<unsigned long, Cs...> (),
296
- math::den<unsigned long, Cs...> (),
297
- math::den_size<unsigned long, Cs...> ()>{};
298
- }
299
-
300
- /**
301
- * @ingroup micro-test-plus-literals
302
- * @brief Operator to convert to `long double`.
303
- */
304
- template <char... Cs>
305
- [[nodiscard]] constexpr auto
306
- operator""_ld ()
307
- {
308
- return type_traits::floating_point_constant<
309
- long double, math::num<unsigned long long, Cs...> (),
310
- math::den<unsigned long long, Cs...> (),
311
- math::den_size<unsigned long long, Cs...> ()>{};
312
- }
313
-
314
- /**
315
- * @ingroup micro-test-plus-literals
316
- * @brief Operator to convert to `bool`.
317
- */
318
- constexpr auto
319
- operator""_b (const char* name, decltype (sizeof ("")) size)
320
- {
321
- struct named : std::string_view, type_traits::op
322
- {
323
- using value_type = bool;
324
- [[nodiscard]] constexpr
325
- operator value_type () const
326
- {
327
- return true;
328
- }
329
-
330
- [[nodiscard]] constexpr auto
331
- operator== (const named&) const
332
- {
333
- return true;
334
- }
335
-
336
- [[nodiscard]] constexpr auto
337
- operator== (const bool other) const
338
- {
339
- return other;
340
- }
341
- };
342
-
343
- return named{ { name, size }, {} };
344
- }
345
- } // namespace literals
346
-
347
- // --------------------------------------------------------------------------
348
-
349
- #if defined(__GNUC__)
350
- #pragma GCC diagnostic push
351
- #if defined(__clang__)
352
- #pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"
353
- #endif
354
- #endif
355
-
356
- /** @deprecated Use `to_b` (since 3.2.0). */
357
- using _b = type_traits::value<bool>;
358
- /** @deprecated Use `to_c` (since 3.2.0). */
359
- using _c = type_traits::value<char>;
360
- /** @deprecated Use `to_sc` (since 3.2.0). */
361
- using _sc = type_traits::value<signed char>;
362
- /** @deprecated Use `to_s` (since 3.2.0). */
363
- using _s = type_traits::value<short>;
364
- /** @deprecated Use `to_i` (since 3.2.0). */
365
- using _i = type_traits::value<int>;
366
- /** @deprecated Use `to_l` (since 3.2.0). */
367
- using _l = type_traits::value<long>;
368
- /** @deprecated Use `to_ll` (since 3.2.0). */
369
- using _ll = type_traits::value<long long>;
370
- /** @deprecated Use `to_u` (since 3.2.0). */
371
- using _u = type_traits::value<unsigned>;
372
- /** @deprecated Use `to_uc` (since 3.2.0). */
373
- using _uc = type_traits::value<unsigned char>;
374
- /** @deprecated Use `to_us` (since 3.2.0). */
375
- using _us = type_traits::value<unsigned short>;
376
- /** @deprecated Use `to_ul` (since 3.2.0). */
377
- using _ul = type_traits::value<unsigned long>;
378
- /** @deprecated Use `to_ull` (since 3.2.0). */
379
- using _ull = type_traits::value<unsigned long long>;
380
- /** @deprecated Use `to_i8` (since 3.2.0). */
381
- using _i8 = type_traits::value<std::int8_t>;
382
- /** @deprecated Use `to_i16` (since 3.2.0). */
383
- using _i16 = type_traits::value<std::int16_t>;
384
- /** @deprecated Use `to_i32` (since 3.2.0). */
385
- using _i32 = type_traits::value<std::int32_t>;
386
- /** @deprecated Use `to_i64` (since 3.2.0). */
387
- using _i64 = type_traits::value<std::int64_t>;
388
- /** @deprecated Use `to_u8` (since 3.2.0). */
389
- using _u8 = type_traits::value<std::uint8_t>;
390
- /** @deprecated Use `to_u16` (since 3.2.0). */
391
- using _u16 = type_traits::value<std::uint16_t>;
392
- /** @deprecated Use `to_u32` (since 3.2.0). */
393
- using _u32 = type_traits::value<std::uint32_t>;
394
- /** @deprecated Use `to_u64` (since 3.2.0). */
395
- using _u64 = type_traits::value<std::uint64_t>;
396
- /** @deprecated Use `to_f` (since 3.2.0). */
397
- using _f = type_traits::value<float>;
398
- /** @deprecated Use `to_d` (since 3.2.0). */
399
- using _d = type_traits::value<double>;
400
- /** @deprecated Use `to_ld` (since 3.2.0). */
401
- using _ld = type_traits::value<long double>;
402
-
403
- /**
404
- * @deprecated Use `to_t` (since 3.2.0).
405
- * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
406
- */
407
- template <class T>
408
- struct _t : type_traits::value<T>
409
- {
410
- constexpr explicit _t (const T& t) : type_traits::value<T>{ t }
411
- {
412
- }
413
- };
414
-
415
- #if defined(__GNUC__)
416
- #pragma GCC diagnostic pop
417
- #endif
418
-
419
- /**
420
- * @addtogroup micro-test-plus-literals
421
- * @{
422
- */
423
-
424
- // Wrappers that can be used to convert dynamic values to specific types
425
- // that are recognised by the comparators.
426
- // The syntax is similar to function calls, like `_i(expression)`, but the
427
- // results have custom types expected by comparators.
428
- /** @since 3.2.0 */
429
- using to_b = type_traits::value<bool>;
430
- /** @since 3.2.0 */
431
- using to_c = type_traits::value<char>;
432
- /** @since 3.2.0 */
433
- using to_sc = type_traits::value<signed char>;
434
- /** @since 3.2.0 */
435
- using to_s = type_traits::value<short>;
436
- /** @since 3.2.0 */
437
- using to_i = type_traits::value<int>;
438
- /** @since 3.2.0 */
439
- using to_l = type_traits::value<long>;
440
- /** @since 3.2.0 */
441
- using to_ll = type_traits::value<long long>;
442
- /** @since 3.2.0 */
443
- using to_u = type_traits::value<unsigned>;
444
- /** @since 3.2.0 */
445
- using to_uc = type_traits::value<unsigned char>;
446
- /** @since 3.2.0 */
447
- using to_us = type_traits::value<unsigned short>;
448
- /** @since 3.2.0 */
449
- using to_ul = type_traits::value<unsigned long>;
450
- /** @since 3.2.0 */
451
- using to_ull = type_traits::value<unsigned long long>;
452
- /** @since 3.2.0 */
453
- using to_i8 = type_traits::value<std::int8_t>;
454
- /** @since 3.2.0 */
455
- using to_i16 = type_traits::value<std::int16_t>;
456
- /** @since 3.2.0 */
457
- using to_i32 = type_traits::value<std::int32_t>;
458
- /** @since 3.2.0 */
459
- using to_i64 = type_traits::value<std::int64_t>;
460
- /** @since 3.2.0 */
461
- using to_u8 = type_traits::value<std::uint8_t>;
462
- /** @since 3.2.0 */
463
- using to_u16 = type_traits::value<std::uint16_t>;
464
- /** @since 3.2.0 */
465
- using to_u32 = type_traits::value<std::uint32_t>;
466
- /** @since 3.2.0 */
467
- using to_u64 = type_traits::value<std::uint64_t>;
468
- /** @since 3.2.0 */
469
- using to_f = type_traits::value<float>;
470
- /** @since 3.2.0 */
471
- using to_d = type_traits::value<double>;
472
- /** @since 3.2.0 */
473
- using to_ld = type_traits::value<long double>;
474
-
475
- /**
476
- * @}
477
- */
478
-
479
- /**
480
- * @ingroup micro-test-plus-literals
481
- * @brief Template for wrapping any other type.
482
- * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
483
- * @since 3.2.0
484
- *
485
- * @details
486
- * A public class used only to convert the type.
487
- */
488
- template <class T>
489
- struct to_t : type_traits::value<T>
490
- {
491
- /** @brief Constructor. */
492
- constexpr explicit to_t (const T& t) : type_traits::value<T>{ t }
493
- {
494
- }
495
- };
496
-
497
- // --------------------------------------------------------------------------
498
- } // namespace micro_os_plus::micro_test_plus
499
-
500
- #if defined(__GNUC__)
501
- #pragma GCC diagnostic pop
502
- #endif
503
-
504
- // ----------------------------------------------------------------------------
505
-
506
- #endif // __cplusplus
507
-
508
- // ----------------------------------------------------------------------------
509
-
510
- #endif // MICRO_TEST_PLUS_LITERALS_H_
511
-
512
- // ----------------------------------------------------------------------------