@micro-os-plus/micro-test-plus 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cmake-format.yaml +11 -0
- package/CHANGELOG.md +352 -2
- package/CMakeLists.txt +32 -30
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/{xcdl.json → config/xcdl-build.json} +6 -6
- package/include/micro-os-plus/micro-test-plus/detail.h +1885 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
- package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
- package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +471 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
- package/include/micro-os-plus/micro-test-plus/math.h +217 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
- package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter.h +801 -0
- package/include/micro-os-plus/micro-test-plus/test-runner.h +241 -0
- package/include/micro-os-plus/micro-test-plus/test-suite.h +456 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
- package/include/micro-os-plus/micro-test-plus.h +169 -551
- package/meson.build +5 -5
- package/package.json +29 -34
- package/src/micro-test-plus.cpp +131 -35
- package/src/test-reporter.cpp +348 -6
- package/src/test-runner.cpp +69 -5
- package/src/test-suite.cpp +124 -5
- package/include/micro-os-plus/detail.h +0 -765
- package/include/micro-os-plus/inlines.h +0 -209
- package/include/micro-os-plus/literals.h +0 -512
- package/include/micro-os-plus/math.h +0 -204
- package/include/micro-os-plus/reflection.h +0 -139
- package/include/micro-os-plus/test-reporter-inlines.h +0 -230
- package/include/micro-os-plus/test-reporter.h +0 -356
- package/include/micro-os-plus/test-runner.h +0 -132
- package/include/micro-os-plus/test-suite.h +0 -306
- package/include/micro-os-plus/type-traits.h +0 -389
|
@@ -0,0 +1,217 @@
|
|
|
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 declarations for the µTest++ mathematical
|
|
21
|
+
* utilities.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the declarations for the mathematical utility templates
|
|
25
|
+
* used within the µTest++ framework. It defines interfaces for a suite of
|
|
26
|
+
* constexpr mathematical functions, including absolute value, minimum value
|
|
27
|
+
* selection, exponentiation, and compile-time parsing of numeric values from
|
|
28
|
+
* character sequences.
|
|
29
|
+
*
|
|
30
|
+
* These utilities are designed to be lightweight and suitable for embedded
|
|
31
|
+
* environments, supporting both integral and floating-point types, and
|
|
32
|
+
* enabling expressive, type-safe, and efficient compile-time computations.
|
|
33
|
+
* Special attention is given to constexpr compatibility and minimal reliance
|
|
34
|
+
* on the standard library, ensuring portability and performance across a wide
|
|
35
|
+
* range of platforms.
|
|
36
|
+
*
|
|
37
|
+
* All definitions reside within the `micro_os_plus::micro_test_plus::math`
|
|
38
|
+
* namespace, ensuring clear separation from user code and minimising the risk
|
|
39
|
+
* of naming conflicts.
|
|
40
|
+
*
|
|
41
|
+
* The header files are organised within the
|
|
42
|
+
* `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
|
|
43
|
+
* modular codebase.
|
|
44
|
+
*
|
|
45
|
+
* This file is intended solely for internal use within the framework and
|
|
46
|
+
* should not be included directly by user code.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
#ifndef MICRO_TEST_PLUS_MATH_H_
|
|
50
|
+
#define MICRO_TEST_PLUS_MATH_H_
|
|
51
|
+
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
#ifdef __cplusplus
|
|
55
|
+
|
|
56
|
+
// ----------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
#include <array>
|
|
59
|
+
|
|
60
|
+
// ----------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
#if defined(__GNUC__)
|
|
63
|
+
#pragma GCC diagnostic push
|
|
64
|
+
#pragma GCC diagnostic ignored "-Wconversion"
|
|
65
|
+
#if defined(__clang__)
|
|
66
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
67
|
+
#endif
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
namespace micro_os_plus::micro_test_plus
|
|
71
|
+
{
|
|
72
|
+
// --------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @namespace micro_os_plus::micro_test_plus::math
|
|
76
|
+
* @brief Mathematical utilities for the µTest++ testing framework.
|
|
77
|
+
*
|
|
78
|
+
* @details
|
|
79
|
+
* The `math` namespace offers a suite of constexpr mathematical
|
|
80
|
+
* function templates and utilities for use within the µTest++ framework.
|
|
81
|
+
*
|
|
82
|
+
* These functions include generic implementations for absolute value,
|
|
83
|
+
* minimum value, exponentiation, and compile-time parsing of numeric values
|
|
84
|
+
* from character arrays. The utilities are designed to be lightweight and
|
|
85
|
+
* suitable for embedded environments, where standard library alternatives
|
|
86
|
+
* may be unavailable, less efficient, or not constexpr.
|
|
87
|
+
*
|
|
88
|
+
* All definitions within this namespace are intended to facilitate
|
|
89
|
+
* mathematical operations in a type-safe and efficient manner, and are
|
|
90
|
+
* implemented in the `include/micro-os-plus` folder to maintain a structured
|
|
91
|
+
* and modular codebase.
|
|
92
|
+
*/
|
|
93
|
+
namespace math
|
|
94
|
+
{
|
|
95
|
+
/**
|
|
96
|
+
* @brief Computes the absolute value of a given comparable value.
|
|
97
|
+
*
|
|
98
|
+
* @tparam T The type of the input value. Must support comparison and unary
|
|
99
|
+
* negation.
|
|
100
|
+
*
|
|
101
|
+
* @param t The value for which the absolute value is to be computed.
|
|
102
|
+
* @return The absolute value of the input.
|
|
103
|
+
*/
|
|
104
|
+
template <class T>
|
|
105
|
+
[[nodiscard]] constexpr auto
|
|
106
|
+
abs (const T t) -> T;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @brief Computes the minimum of two comparable values.
|
|
110
|
+
*
|
|
111
|
+
* @tparam T The type of the input values. Must support comparison via the
|
|
112
|
+
* `<` operator.
|
|
113
|
+
*
|
|
114
|
+
* @param lhs The first value to compare.
|
|
115
|
+
* @param rhs The second value to compare.
|
|
116
|
+
* @return A reference to the minimum of the two input values.
|
|
117
|
+
*/
|
|
118
|
+
template <class T>
|
|
119
|
+
[[nodiscard]] constexpr auto
|
|
120
|
+
min_value (const T& lhs, const T& rhs) -> const T&;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @brief Generic exponentiation function to compute the power of a base
|
|
124
|
+
* raised to an exponent.
|
|
125
|
+
*
|
|
126
|
+
* @tparam T The type of the base value. Must support multiplication and
|
|
127
|
+
* construction from an integer.
|
|
128
|
+
* @tparam Exp_T The type of the exponent. Must support subtraction and
|
|
129
|
+
* comparison to zero.
|
|
130
|
+
*
|
|
131
|
+
* @param base The base value to be raised to the power of \p exp.
|
|
132
|
+
* @param exp The exponent value.
|
|
133
|
+
* @return The result of raising \p base to the power of \p exp.
|
|
134
|
+
*/
|
|
135
|
+
template <class T, class Exp_T>
|
|
136
|
+
[[nodiscard]] constexpr auto
|
|
137
|
+
pow (const T base, const Exp_T exp) -> T;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @brief Computes the integral value of a number represented as an array
|
|
141
|
+
* of characters.
|
|
142
|
+
*
|
|
143
|
+
* @tparam T The target integral type for the result.
|
|
144
|
+
* @tparam Cs The character pack representing the numeric value.
|
|
145
|
+
*
|
|
146
|
+
* @par Parameters
|
|
147
|
+
* None.
|
|
148
|
+
* @return The parsed integral value of type \c T.
|
|
149
|
+
*/
|
|
150
|
+
template <class T, char... Cs>
|
|
151
|
+
[[nodiscard]] constexpr auto
|
|
152
|
+
num (void) -> T;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @brief Computes the decimal part of a number represented as an array of
|
|
156
|
+
* characters.
|
|
157
|
+
*
|
|
158
|
+
* @tparam T The target integral type for the result.
|
|
159
|
+
* @tparam Cs The character pack representing the numeric value.
|
|
160
|
+
*
|
|
161
|
+
* @par Parameters
|
|
162
|
+
* None.
|
|
163
|
+
* @return The parsed decimal part as an integral value of type \c T.
|
|
164
|
+
*/
|
|
165
|
+
template <class T, char... Cs>
|
|
166
|
+
[[nodiscard]] constexpr auto
|
|
167
|
+
den (void) -> T;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @brief Computes the number of decimal places in a number represented as
|
|
171
|
+
* an array of characters.
|
|
172
|
+
*
|
|
173
|
+
* @tparam T The integral type for the result.
|
|
174
|
+
* @tparam Cs The character pack representing the numeric value.
|
|
175
|
+
*
|
|
176
|
+
* @par Parameters
|
|
177
|
+
* None.
|
|
178
|
+
* @return The number of decimal places as a value of type \c T.
|
|
179
|
+
*/
|
|
180
|
+
template <class T, char... Cs>
|
|
181
|
+
[[nodiscard]] constexpr auto
|
|
182
|
+
den_size (void) -> T;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @brief Computes the number of decimal places of a value, up to 7 digits.
|
|
186
|
+
*
|
|
187
|
+
* @tparam T The integral type for the result.
|
|
188
|
+
* @tparam Value_T The type of the input value, typically a floating-point
|
|
189
|
+
* type.
|
|
190
|
+
*
|
|
191
|
+
* @param value The value whose decimal precision is to be determined.
|
|
192
|
+
* @return The number of decimal places, as a value of type \c T, up to a
|
|
193
|
+
* maximum of seven.
|
|
194
|
+
*/
|
|
195
|
+
template <class T, class Value_T>
|
|
196
|
+
[[nodiscard]] constexpr auto
|
|
197
|
+
den_size (Value_T value) -> T;
|
|
198
|
+
|
|
199
|
+
// ------------------------------------------------------------------------
|
|
200
|
+
} // namespace math
|
|
201
|
+
|
|
202
|
+
// --------------------------------------------------------------------------
|
|
203
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
204
|
+
|
|
205
|
+
#if defined(__GNUC__)
|
|
206
|
+
#pragma GCC diagnostic pop
|
|
207
|
+
#endif
|
|
208
|
+
|
|
209
|
+
// ----------------------------------------------------------------------------
|
|
210
|
+
|
|
211
|
+
#endif // __cplusplus
|
|
212
|
+
|
|
213
|
+
// ----------------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
#endif // MICRO_TEST_PLUS_MATH_H_
|
|
216
|
+
|
|
217
|
+
// ----------------------------------------------------------------------------
|