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