@micro-os-plus/micro-test-plus 4.0.0 → 4.1.1
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 +95 -0
- package/CMakeLists.txt +74 -24
- package/README.md +3 -2
- package/include/micro-os-plus/micro-test-plus/README.md +6 -0
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +29 -54
- package/include/micro-os-plus/micro-test-plus/detail.h +166 -705
- package/include/micro-os-plus/micro-test-plus/exceptions.h +5 -6
- package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +5 -0
- package/include/micro-os-plus/micro-test-plus/inlines/deferred-reporter-inlines.h +25 -30
- 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/expression-formatter-inlines.h +510 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +17 -76
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +47 -25
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +7 -7
- 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 +4 -4
- package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +53 -394
- package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +38 -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 +231 -45
- 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 +202 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +8 -14
- package/include/micro-os-plus/micro-test-plus/math.h +5 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +19 -169
- package/include/micro-os-plus/micro-test-plus/reflection.h +5 -12
- package/include/micro-os-plus/micro-test-plus/reporter-human.h +17 -11
- package/include/micro-os-plus/micro-test-plus/reporter-tap.h +14 -8
- package/include/micro-os-plus/micro-test-plus/reporter.h +101 -424
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +162 -176
- package/include/micro-os-plus/micro-test-plus/runner.h +61 -42
- package/include/micro-os-plus/micro-test-plus/test.h +450 -506
- package/include/micro-os-plus/micro-test-plus/timings.h +259 -262
- package/include/micro-os-plus/micro-test-plus/type-traits.h +30 -52
- package/include/micro-os-plus/micro-test-plus/utility.h +5 -4
- package/include/micro-os-plus/micro-test-plus.h +33 -24
- package/meson.build +1 -0
- package/package.json +11 -3
- package/src/deferred-reporter.cpp +21 -2
- package/src/expression-formatter.cpp +289 -0
- package/src/reflection.cpp +3 -1
- package/src/reporter-human.cpp +31 -37
- package/src/reporter-tap.cpp +25 -35
- package/src/reporter.cpp +36 -231
- package/src/runner-totals.cpp +6 -3
- package/src/runner.cpp +131 -25
- package/src/test.cpp +120 -113
- package/src/timings.cpp +6 -5
- package/src/utility.cpp +1 -1
|
@@ -0,0 +1,275 @@
|
|
|
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
|
+
* operator overloads.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the inline implementations for all operator overloads
|
|
25
|
+
* declared in `operators.h`. Each operator constructs and returns the
|
|
26
|
+
* appropriate comparator or logical object from the `detail` namespace.
|
|
27
|
+
*
|
|
28
|
+
* Separating the implementations from the declarations keeps `operators.h`
|
|
29
|
+
* concise and focused on the interface, whilst grouping all operator bodies
|
|
30
|
+
* here for maintainability.
|
|
31
|
+
*
|
|
32
|
+
* All definitions reside within the
|
|
33
|
+
* `micro_os_plus::micro_test_plus::operators` namespace, ensuring clear
|
|
34
|
+
* separation from user code and minimising the risk of naming conflicts.
|
|
35
|
+
*
|
|
36
|
+
* This file is intended solely for internal use within the framework and
|
|
37
|
+
* should not be included directly by user code.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
#ifndef MICRO_TEST_PLUS_OPERATORS_INLINES_H_
|
|
41
|
+
#define MICRO_TEST_PLUS_OPERATORS_INLINES_H_
|
|
42
|
+
|
|
43
|
+
// ----------------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
#ifdef __cplusplus
|
|
46
|
+
|
|
47
|
+
// ----------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
#include "micro-os-plus/micro-test-plus/detail.h"
|
|
50
|
+
|
|
51
|
+
// ----------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
#if defined(__GNUC__)
|
|
54
|
+
#pragma GCC diagnostic push
|
|
55
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
56
|
+
#if defined(__clang__)
|
|
57
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
58
|
+
#endif
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
|
|
63
|
+
namespace micro_os_plus::micro_test_plus
|
|
64
|
+
{
|
|
65
|
+
namespace operators
|
|
66
|
+
{
|
|
67
|
+
// ========================================================================
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @details
|
|
71
|
+
* Constructs an `eq_` comparator object from the two `string_view`
|
|
72
|
+
* operands and returns it. The comparator evaluates to `true` if the
|
|
73
|
+
* string views are equal.
|
|
74
|
+
*/
|
|
75
|
+
constexpr auto
|
|
76
|
+
operator== (std::string_view lhs, std::string_view rhs)
|
|
77
|
+
{
|
|
78
|
+
return detail::eq_{ lhs, rhs };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @details
|
|
83
|
+
* Constructs an `ne_` comparator object from the two `string_view`
|
|
84
|
+
* operands and returns it. The comparator evaluates to `true` if the
|
|
85
|
+
* string views are not equal.
|
|
86
|
+
*/
|
|
87
|
+
constexpr auto
|
|
88
|
+
operator!= (std::string_view lhs, std::string_view rhs)
|
|
89
|
+
{
|
|
90
|
+
return detail::ne_{ lhs, rhs };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @details
|
|
95
|
+
* Constructs an `eq_` comparator object from the two container
|
|
96
|
+
* operands and returns it. The comparator evaluates to `true` if the
|
|
97
|
+
* containers are equal in content and order.
|
|
98
|
+
*
|
|
99
|
+
* The operator is enabled only for types recognised as containers by the
|
|
100
|
+
* framework's type traits.
|
|
101
|
+
*/
|
|
102
|
+
template <class Lhs_T, class Rhs_T>
|
|
103
|
+
requires (type_traits::container_like<Lhs_T>
|
|
104
|
+
and type_traits::container_like<Rhs_T>)
|
|
105
|
+
constexpr auto
|
|
106
|
+
operator== (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
107
|
+
{
|
|
108
|
+
return detail::eq_{ lhs, rhs };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @details
|
|
113
|
+
* Constructs an `ne_` comparator object from the two container
|
|
114
|
+
* operands and returns it. The comparator evaluates to `true` if the
|
|
115
|
+
* containers are not equal in content or order.
|
|
116
|
+
*
|
|
117
|
+
* The operator is enabled only for types recognised as containers by the
|
|
118
|
+
* framework's type traits.
|
|
119
|
+
*/
|
|
120
|
+
template <class Lhs_T, class Rhs_T>
|
|
121
|
+
requires (type_traits::container_like<Lhs_T>
|
|
122
|
+
and type_traits::container_like<Rhs_T>)
|
|
123
|
+
constexpr auto
|
|
124
|
+
operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
125
|
+
{
|
|
126
|
+
return detail::ne_{ lhs, rhs };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @details
|
|
131
|
+
* Constructs an `eq_` comparator object from the two operands and
|
|
132
|
+
* returns it. The comparator evaluates to `true` if the operands are
|
|
133
|
+
* equal. At least one operand must derive from the local `op` base.
|
|
134
|
+
*/
|
|
135
|
+
template <class Lhs_T, class Rhs_T>
|
|
136
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
137
|
+
constexpr auto
|
|
138
|
+
operator== (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
139
|
+
{
|
|
140
|
+
return detail::eq_{ lhs, rhs };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @details
|
|
145
|
+
* Constructs an `ne_` comparator object from the two operands and
|
|
146
|
+
* returns it. The comparator evaluates to `true` if the operands are
|
|
147
|
+
* not equal. At least one operand must derive from the local `op` base.
|
|
148
|
+
*/
|
|
149
|
+
template <class Lhs_T, class Rhs_T>
|
|
150
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
151
|
+
constexpr auto
|
|
152
|
+
operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
153
|
+
{
|
|
154
|
+
return detail::ne_{ lhs, rhs };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @details
|
|
159
|
+
* Constructs a `gt_` comparator object from the two operands and
|
|
160
|
+
* returns it. The comparator evaluates to `true` if `lhs` is greater
|
|
161
|
+
* than `rhs`. At least one operand must derive from the local `op` base.
|
|
162
|
+
*/
|
|
163
|
+
template <class Lhs_T, class Rhs_T>
|
|
164
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
165
|
+
constexpr auto
|
|
166
|
+
operator> (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
167
|
+
{
|
|
168
|
+
return detail::gt_{ lhs, rhs };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @details
|
|
173
|
+
* Constructs a `ge_` comparator object from the two operands and
|
|
174
|
+
* returns it. The comparator evaluates to `true` if `lhs` is greater
|
|
175
|
+
* than or equal to `rhs`. At least one operand must derive from the
|
|
176
|
+
* local `op` base.
|
|
177
|
+
*/
|
|
178
|
+
template <class Lhs_T, class Rhs_T>
|
|
179
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
180
|
+
constexpr auto
|
|
181
|
+
operator>= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
182
|
+
{
|
|
183
|
+
return detail::ge_{ lhs, rhs };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @details
|
|
188
|
+
* Constructs an `lt_` comparator object from the two operands and
|
|
189
|
+
* returns it. The comparator evaluates to `true` if `lhs` is less
|
|
190
|
+
* than `rhs`. At least one operand must derive from the local `op` base.
|
|
191
|
+
*/
|
|
192
|
+
template <class Lhs_T, class Rhs_T>
|
|
193
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
194
|
+
constexpr auto
|
|
195
|
+
operator< (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
196
|
+
{
|
|
197
|
+
return detail::lt_{ lhs, rhs };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @details
|
|
202
|
+
* Constructs an `le_` comparator object from the two operands and
|
|
203
|
+
* returns it. The comparator evaluates to `true` if `lhs` is less than
|
|
204
|
+
* or equal to `rhs`. At least one operand must derive from the local
|
|
205
|
+
* `op` base.
|
|
206
|
+
*/
|
|
207
|
+
template <class Lhs_T, class Rhs_T>
|
|
208
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
209
|
+
constexpr auto
|
|
210
|
+
operator<= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
211
|
+
{
|
|
212
|
+
return detail::le_{ lhs, rhs };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @details
|
|
217
|
+
* Constructs an `and_` logical conjunction object from the two operands
|
|
218
|
+
* and returns it. The object evaluates to `true` if both operands are
|
|
219
|
+
* true. At least one operand must derive from the local `op` base.
|
|
220
|
+
*/
|
|
221
|
+
template <class Lhs_T, class Rhs_T>
|
|
222
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
223
|
+
constexpr auto
|
|
224
|
+
operator and (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
225
|
+
{
|
|
226
|
+
return detail::and_{ lhs, rhs };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @details
|
|
231
|
+
* Constructs an `or_` logical disjunction object from the two operands
|
|
232
|
+
* and returns it. The object evaluates to `true` if at least one operand
|
|
233
|
+
* is true. At least one operand must derive from the local `op` base.
|
|
234
|
+
*/
|
|
235
|
+
template <class Lhs_T, class Rhs_T>
|
|
236
|
+
requires type_traits::any_op<Lhs_T, Rhs_T>
|
|
237
|
+
constexpr auto
|
|
238
|
+
operator or (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
239
|
+
{
|
|
240
|
+
return detail::or_{ lhs, rhs };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @details
|
|
245
|
+
* Constructs a `not_` logical negator object from the operand and
|
|
246
|
+
* returns it. The object evaluates to `true` if the operand is false.
|
|
247
|
+
* The operand must derive from the local `op` base.
|
|
248
|
+
*/
|
|
249
|
+
template <class T>
|
|
250
|
+
requires type_traits::is_op<T>
|
|
251
|
+
constexpr auto
|
|
252
|
+
operator not(const T& t)
|
|
253
|
+
{
|
|
254
|
+
return detail::not_{ t };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ------------------------------------------------------------------------
|
|
258
|
+
} // namespace operators
|
|
259
|
+
|
|
260
|
+
// --------------------------------------------------------------------------
|
|
261
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
262
|
+
|
|
263
|
+
#if defined(__GNUC__)
|
|
264
|
+
#pragma GCC diagnostic pop
|
|
265
|
+
#endif
|
|
266
|
+
|
|
267
|
+
// ----------------------------------------------------------------------------
|
|
268
|
+
|
|
269
|
+
#endif // __cplusplus
|
|
270
|
+
|
|
271
|
+
// ----------------------------------------------------------------------------
|
|
272
|
+
|
|
273
|
+
#endif // MICRO_TEST_PLUS_OPERATORS_INLINES_H_
|
|
274
|
+
|
|
275
|
+
// ----------------------------------------------------------------------------
|
|
@@ -87,7 +87,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
87
87
|
* If supported by the compiler, uses built-in macros to capture this
|
|
88
88
|
* information; otherwise, defaults to `"unknown"` and zero.
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
constexpr source_location
|
|
91
91
|
source_location::current (const char* file, unsigned int line) noexcept
|
|
92
92
|
{
|
|
93
93
|
source_location sl{};
|
|
@@ -101,7 +101,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
101
101
|
* Returns the file name captured at the time this `source_location`
|
|
102
102
|
* instance was created.
|
|
103
103
|
*/
|
|
104
|
-
|
|
104
|
+
constexpr auto
|
|
105
105
|
source_location::file_name (void) const noexcept
|
|
106
106
|
{
|
|
107
107
|
return file_;
|
|
@@ -112,7 +112,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
112
112
|
* Returns the line number captured at the time this `source_location`
|
|
113
113
|
* instance was created.
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
constexpr auto
|
|
116
116
|
source_location::line (void) const noexcept
|
|
117
117
|
{
|
|
118
118
|
return line_;
|
|
@@ -141,7 +141,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
141
141
|
* changes, and compiler format updates.
|
|
142
142
|
*/
|
|
143
143
|
template <class T>
|
|
144
|
-
|
|
144
|
+
constexpr auto
|
|
145
145
|
type_name (void) -> std::string_view
|
|
146
146
|
{
|
|
147
147
|
const std::string_view sv = __PRETTY_FUNCTION__;
|