@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
|
@@ -0,0 +1,231 @@
|
|
|
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++
|
|
21
|
+
* type trait utilities.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the out-of-class template and inline implementations
|
|
25
|
+
* for all methods declared in the type-traits struct templates in
|
|
26
|
+
* `type-traits.h`. It defines the bodies of the constructors, conversion
|
|
27
|
+
* operators, and accessor methods for `value_base_`, `integral_constant`,
|
|
28
|
+
* `floating_point_constant`, `genuine_integral_value`, and the `value<T>`
|
|
29
|
+
* templates.
|
|
30
|
+
*
|
|
31
|
+
* Separating the implementations from the declarations keeps `type-traits.h`
|
|
32
|
+
* concise and focused on the interface, whilst grouping all method bodies
|
|
33
|
+
* here for maintainability.
|
|
34
|
+
*
|
|
35
|
+
* All definitions reside within the
|
|
36
|
+
* `micro_os_plus::micro_test_plus::type_traits` namespace, ensuring clear
|
|
37
|
+
* separation from user code and minimising the risk of naming conflicts.
|
|
38
|
+
*
|
|
39
|
+
* This file is intended solely for internal use within the framework and
|
|
40
|
+
* should not be included directly by user code.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
#ifndef MICRO_TEST_PLUS_TYPE_TRAITS_INLINES_H_
|
|
44
|
+
#define MICRO_TEST_PLUS_TYPE_TRAITS_INLINES_H_
|
|
45
|
+
|
|
46
|
+
// ----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
#ifdef __cplusplus
|
|
49
|
+
|
|
50
|
+
// ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
#if defined(__GNUC__)
|
|
53
|
+
#pragma GCC diagnostic push
|
|
54
|
+
#if defined(__clang__)
|
|
55
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
56
|
+
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
57
|
+
#endif
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
// ============================================================================
|
|
61
|
+
|
|
62
|
+
namespace micro_os_plus::micro_test_plus
|
|
63
|
+
{
|
|
64
|
+
namespace type_traits
|
|
65
|
+
{
|
|
66
|
+
// ========================================================================
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @details
|
|
70
|
+
* Stores the supplied value in the `value_` member.
|
|
71
|
+
*/
|
|
72
|
+
template <class T>
|
|
73
|
+
constexpr value_base_<T>::value_base_ (const T& v) noexcept : value_{ v }
|
|
74
|
+
{
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @details
|
|
79
|
+
* Allows explicit conversion to the encapsulated value.
|
|
80
|
+
*/
|
|
81
|
+
template <class T>
|
|
82
|
+
constexpr value_base_<T>::
|
|
83
|
+
operator T () const noexcept
|
|
84
|
+
{
|
|
85
|
+
return value_;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @details
|
|
90
|
+
* Returns the stored value by value.
|
|
91
|
+
*/
|
|
92
|
+
template <class T>
|
|
93
|
+
constexpr T
|
|
94
|
+
value_base_<T>::get (void) const noexcept
|
|
95
|
+
{
|
|
96
|
+
return value_;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ------------------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @details
|
|
103
|
+
* Delegates to `value_base_<decltype(N)>{ N }` to initialise the base.
|
|
104
|
+
*/
|
|
105
|
+
template <auto N>
|
|
106
|
+
constexpr integral_constant<N>::integral_constant () noexcept
|
|
107
|
+
: value_base_<decltype (N)>{ N }
|
|
108
|
+
{
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @details
|
|
113
|
+
* Returns a new `integral_constant` instance representing the negative
|
|
114
|
+
* of the current value.
|
|
115
|
+
*/
|
|
116
|
+
template <auto N>
|
|
117
|
+
constexpr auto
|
|
118
|
+
integral_constant<N>::operator- () const noexcept
|
|
119
|
+
{
|
|
120
|
+
return integral_constant<-N>{};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @details
|
|
127
|
+
* Returns the compile-time constant value as type `T`.
|
|
128
|
+
*/
|
|
129
|
+
template <class T, auto N, auto D, auto Size, auto P>
|
|
130
|
+
constexpr floating_point_constant<T, N, D, Size, P>::
|
|
131
|
+
operator T () const noexcept
|
|
132
|
+
{
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @details
|
|
138
|
+
* Returns the compile-time constant value as type `T`.
|
|
139
|
+
*/
|
|
140
|
+
template <class T, auto N, auto D, auto Size, auto P>
|
|
141
|
+
constexpr T
|
|
142
|
+
floating_point_constant<T, N, D, Size, P>::get (void) const noexcept
|
|
143
|
+
{
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @details
|
|
149
|
+
* Returns a new `floating_point_constant` instance representing the
|
|
150
|
+
* negative of the current value by flipping the sign parameter `P`.
|
|
151
|
+
*/
|
|
152
|
+
template <class T, auto N, auto D, auto Size, auto P>
|
|
153
|
+
constexpr auto
|
|
154
|
+
floating_point_constant<T, N, D, Size, P>::operator- () const noexcept
|
|
155
|
+
{
|
|
156
|
+
return floating_point_constant<T, N, D, Size, -P>{};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @details
|
|
163
|
+
* Delegates to `value_base_<T>{ _value }` to initialise the base.
|
|
164
|
+
*/
|
|
165
|
+
template <class T>
|
|
166
|
+
constexpr genuine_integral_value<T>::genuine_integral_value (
|
|
167
|
+
const T& _value) noexcept
|
|
168
|
+
: value_base_<T>{ _value }
|
|
169
|
+
{
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ------------------------------------------------------------------------
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @details
|
|
176
|
+
* Delegates to `value_base_<T>{ _value }` to initialise the base.
|
|
177
|
+
*/
|
|
178
|
+
template <class T>
|
|
179
|
+
constexpr value<T>::value (const T& _value) noexcept
|
|
180
|
+
: value_base_<T>{ _value }
|
|
181
|
+
{
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ------------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @details
|
|
188
|
+
* Delegates to `value_base_<T>{ _value }` and stores the supplied
|
|
189
|
+
* precision in `epsilon`.
|
|
190
|
+
*/
|
|
191
|
+
template <class T>
|
|
192
|
+
requires is_floating_point<T>
|
|
193
|
+
constexpr value<T>::value (const T& _value, const T precision) noexcept
|
|
194
|
+
: value_base_<T>{ _value }, epsilon{ precision }
|
|
195
|
+
{
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @details
|
|
200
|
+
* The epsilon is computed as 1 divided by 10 raised to the number of
|
|
201
|
+
* decimal digits in the value.
|
|
202
|
+
*/
|
|
203
|
+
template <class T>
|
|
204
|
+
requires is_floating_point<T>
|
|
205
|
+
constexpr value<T>::value (const T& val)
|
|
206
|
+
: value{ val,
|
|
207
|
+
T (1)
|
|
208
|
+
/ math::pow (T (10),
|
|
209
|
+
math::den_size<unsigned long long> (val)) }
|
|
210
|
+
{
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// ------------------------------------------------------------------------
|
|
214
|
+
} // namespace type_traits
|
|
215
|
+
|
|
216
|
+
// --------------------------------------------------------------------------
|
|
217
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
218
|
+
|
|
219
|
+
#if defined(__GNUC__)
|
|
220
|
+
#pragma GCC diagnostic pop
|
|
221
|
+
#endif
|
|
222
|
+
|
|
223
|
+
// ----------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
#endif // __cplusplus
|
|
226
|
+
|
|
227
|
+
// ----------------------------------------------------------------------------
|
|
228
|
+
|
|
229
|
+
#endif // MICRO_TEST_PLUS_TYPE_TRAITS_INLINES_H_
|
|
230
|
+
|
|
231
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,126 @@
|
|
|
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++ utility
|
|
21
|
+
* functions.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the inline implementations for the utility function
|
|
25
|
+
* templates used within the µTest++ framework. It defines the logic for
|
|
26
|
+
* splitting strings into substrings using a specified delimiter, enabling
|
|
27
|
+
* convenient and type-safe string parsing in test expressions.
|
|
28
|
+
*
|
|
29
|
+
* All definitions reside within the
|
|
30
|
+
* `micro_os_plus::micro_test_plus::utility` namespace, ensuring clear
|
|
31
|
+
* separation from user code and minimising the risk of naming conflicts.
|
|
32
|
+
*
|
|
33
|
+
* The header files are organised within the
|
|
34
|
+
* `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
|
|
35
|
+
* modular codebase.
|
|
36
|
+
*
|
|
37
|
+
* This file is intended solely for internal use within the framework and
|
|
38
|
+
* should not be included directly by user code.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
#ifndef MICRO_TEST_PLUS_UTILITY_INLINES_H_
|
|
42
|
+
#define MICRO_TEST_PLUS_UTILITY_INLINES_H_
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#ifdef __cplusplus
|
|
47
|
+
|
|
48
|
+
// ----------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
#if defined(__GNUC__)
|
|
51
|
+
#pragma GCC diagnostic push
|
|
52
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
53
|
+
#if defined(__clang__)
|
|
54
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
55
|
+
#endif
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
// ============================================================================
|
|
59
|
+
|
|
60
|
+
namespace micro_os_plus::micro_test_plus
|
|
61
|
+
{
|
|
62
|
+
// --------------------------------------------------------------------------
|
|
63
|
+
namespace utility
|
|
64
|
+
{
|
|
65
|
+
/**
|
|
66
|
+
* @details
|
|
67
|
+
* This function template facilitates string handling in tests by splitting
|
|
68
|
+
* a string into a vector of substrings, using the specified delimiter.
|
|
69
|
+
*
|
|
70
|
+
* The function iterates through the input string, identifying delimiter
|
|
71
|
+
* positions and extracting substrings between them. Each resulting
|
|
72
|
+
* substring is added to the output vector. This approach supports flexible
|
|
73
|
+
* parsing of delimited data, which is particularly useful for validating
|
|
74
|
+
* string processing logic in test cases.
|
|
75
|
+
*
|
|
76
|
+
* **Example**
|
|
77
|
+
*
|
|
78
|
+
* @code{.cpp}
|
|
79
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
80
|
+
*
|
|
81
|
+
* t.expect (std::vector<std::string_view>{ "a", "b" }
|
|
82
|
+
* == mt::utility::split<std::string_view> ("a.b", "."))
|
|
83
|
+
* << "a.b splits into [a,b]";
|
|
84
|
+
* @endcode
|
|
85
|
+
*/
|
|
86
|
+
template <class T = std::string_view, class Delim_T>
|
|
87
|
+
[[nodiscard]] auto
|
|
88
|
+
split (T input, Delim_T delim) -> std::vector<T>
|
|
89
|
+
{
|
|
90
|
+
std::vector<T> output{};
|
|
91
|
+
std::size_t first{};
|
|
92
|
+
while (first < std::size (input))
|
|
93
|
+
{
|
|
94
|
+
const auto second = input.find_first_of (delim, first);
|
|
95
|
+
if (first != second)
|
|
96
|
+
{
|
|
97
|
+
output.emplace_back (input.substr (first, second - first));
|
|
98
|
+
}
|
|
99
|
+
if (second == T::npos)
|
|
100
|
+
{
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
first = second + 1;
|
|
104
|
+
}
|
|
105
|
+
return output;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ------------------------------------------------------------------------
|
|
109
|
+
} // namespace utility
|
|
110
|
+
|
|
111
|
+
// --------------------------------------------------------------------------
|
|
112
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
113
|
+
|
|
114
|
+
#if defined(__GNUC__)
|
|
115
|
+
#pragma GCC diagnostic pop
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
// ----------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
#endif // __cplusplus
|
|
121
|
+
|
|
122
|
+
// ----------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
#endif // MICRO_TEST_PLUS_UTILITY_INLINES_H_
|
|
125
|
+
|
|
126
|
+
// ----------------------------------------------------------------------------
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
// ----------------------------------------------------------------------------
|
|
61
61
|
|
|
62
62
|
#include <cstdint>
|
|
63
|
+
|
|
63
64
|
#include "type-traits.h"
|
|
64
65
|
#include "math.h"
|
|
65
66
|
|
|
@@ -74,6 +75,8 @@
|
|
|
74
75
|
#endif
|
|
75
76
|
#endif
|
|
76
77
|
|
|
78
|
+
// =============================================================================
|
|
79
|
+
|
|
77
80
|
namespace micro_os_plus::micro_test_plus
|
|
78
81
|
{
|
|
79
82
|
// --------------------------------------------------------------------------
|
|
@@ -324,7 +327,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
324
327
|
*
|
|
325
328
|
* @return A `type_traits::integral_constant` instance holding the parsed
|
|
326
329
|
* `uint8_t` value.
|
|
327
|
-
* and reporting mechanisms.
|
|
328
330
|
*/
|
|
329
331
|
template <char... Cs>
|
|
330
332
|
[[nodiscard]] constexpr auto
|
|
@@ -642,14 +644,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
642
644
|
* @brief Constructor for the deprecated strongly-typed wrapper.
|
|
643
645
|
*
|
|
644
646
|
* @param t The value to be wrapped and explicitly converted.
|
|
645
|
-
*
|
|
646
|
-
* @details
|
|
647
|
-
* Constructs an `_t` instance by forwarding the provided value to the base
|
|
648
|
-
* `type_traits::value<T>` wrapper.
|
|
649
647
|
*/
|
|
650
|
-
constexpr explicit _t (const T& t)
|
|
651
|
-
{
|
|
652
|
-
}
|
|
648
|
+
constexpr explicit _t (const T& t);
|
|
653
649
|
};
|
|
654
650
|
|
|
655
651
|
#if defined(__GNUC__)
|
|
@@ -675,8 +671,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
675
671
|
*
|
|
676
672
|
* @code
|
|
677
673
|
* int x = 42;
|
|
678
|
-
*
|
|
679
|
-
*
|
|
674
|
+
* // Explicitly treat x as an int for test comparison.
|
|
675
|
+
* auto wrapped = to_i{x};
|
|
680
676
|
* @endcode
|
|
681
677
|
*
|
|
682
678
|
* @since 3.2.0
|
|
@@ -884,14 +880,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
884
880
|
* @brief Constructor for the strongly-typed wrapper.
|
|
885
881
|
*
|
|
886
882
|
* @param t The value to be wrapped and explicitly converted.
|
|
887
|
-
*
|
|
888
|
-
* @details
|
|
889
|
-
* Constructs a `to_t` instance by forwarding the provided value to the
|
|
890
|
-
* base `type_traits::value<T>` wrapper.
|
|
891
883
|
*/
|
|
892
|
-
constexpr explicit to_t (const T& t)
|
|
893
|
-
{
|
|
894
|
-
}
|
|
884
|
+
constexpr explicit to_t (const T& t);
|
|
895
885
|
};
|
|
896
886
|
|
|
897
887
|
// --------------------------------------------------------------------------
|
|
@@ -905,6 +895,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
905
895
|
|
|
906
896
|
#endif // __cplusplus
|
|
907
897
|
|
|
898
|
+
// ============================================================================
|
|
899
|
+
// Templates & constexpr implementations.
|
|
900
|
+
|
|
901
|
+
#include "inlines/literals-inlines.h"
|
|
902
|
+
|
|
908
903
|
// ----------------------------------------------------------------------------
|
|
909
904
|
|
|
910
905
|
#endif // MICRO_TEST_PLUS_LITERALS_H_
|
|
@@ -64,9 +64,12 @@
|
|
|
64
64
|
#pragma GCC diagnostic ignored "-Wconversion"
|
|
65
65
|
#if defined(__clang__)
|
|
66
66
|
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
67
|
+
#pragma clang diagnostic ignored "-Wc++20-compat"
|
|
67
68
|
#endif
|
|
68
69
|
#endif
|
|
69
70
|
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
70
73
|
namespace micro_os_plus::micro_test_plus
|
|
71
74
|
{
|
|
72
75
|
// --------------------------------------------------------------------------
|
|
@@ -103,7 +106,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
103
106
|
*/
|
|
104
107
|
template <class T>
|
|
105
108
|
[[nodiscard]] constexpr auto
|
|
106
|
-
abs (const T t) -> T;
|
|
109
|
+
abs (const T t) noexcept -> T;
|
|
107
110
|
|
|
108
111
|
/**
|
|
109
112
|
* @brief Computes the minimum of two comparable values.
|
|
@@ -117,7 +120,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
117
120
|
*/
|
|
118
121
|
template <class T>
|
|
119
122
|
[[nodiscard]] constexpr auto
|
|
120
|
-
min_value (const T& lhs, const T& rhs) -> const T&;
|
|
123
|
+
min_value (const T& lhs, const T& rhs) noexcept -> const T&;
|
|
121
124
|
|
|
122
125
|
/**
|
|
123
126
|
* @brief Generic exponentiation function to compute the power of a base
|
|
@@ -134,7 +137,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
134
137
|
*/
|
|
135
138
|
template <class T, class Exp_T>
|
|
136
139
|
[[nodiscard]] constexpr auto
|
|
137
|
-
pow (const T base, const Exp_T exp) -> T;
|
|
140
|
+
pow (const T base, const Exp_T exp) noexcept -> T;
|
|
138
141
|
|
|
139
142
|
/**
|
|
140
143
|
* @brief Computes the integral value of a number represented as an array
|
|
@@ -148,7 +151,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
148
151
|
* @return The parsed integral value of type \c T.
|
|
149
152
|
*/
|
|
150
153
|
template <class T, char... Cs>
|
|
151
|
-
[[nodiscard]]
|
|
154
|
+
[[nodiscard]] consteval auto
|
|
152
155
|
num (void) -> T;
|
|
153
156
|
|
|
154
157
|
/**
|
|
@@ -163,7 +166,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
163
166
|
* @return The parsed decimal part as an integral value of type \c T.
|
|
164
167
|
*/
|
|
165
168
|
template <class T, char... Cs>
|
|
166
|
-
[[nodiscard]]
|
|
169
|
+
[[nodiscard]] consteval auto
|
|
167
170
|
den (void) -> T;
|
|
168
171
|
|
|
169
172
|
/**
|
|
@@ -178,7 +181,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
178
181
|
* @return The number of decimal places as a value of type \c T.
|
|
179
182
|
*/
|
|
180
183
|
template <class T, char... Cs>
|
|
181
|
-
[[nodiscard]]
|
|
184
|
+
[[nodiscard]] consteval auto
|
|
182
185
|
den_size (void) -> T;
|
|
183
186
|
|
|
184
187
|
/**
|
|
@@ -210,6 +213,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
210
213
|
|
|
211
214
|
#endif // __cplusplus
|
|
212
215
|
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Templates & constexpr implementations.
|
|
218
|
+
|
|
219
|
+
#include "inlines/math-inlines.h"
|
|
220
|
+
|
|
213
221
|
// ----------------------------------------------------------------------------
|
|
214
222
|
|
|
215
223
|
#endif // MICRO_TEST_PLUS_MATH_H_
|