@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.
- package/.cmake-format.yaml +11 -0
- package/CHANGELOG.md +417 -2
- package/CMakeLists.txt +33 -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 +1908 -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 +476 -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-basic.h +289 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter-tap.h +281 -0
- package/include/micro-os-plus/micro-test-plus/test-reporter.h +846 -0
- package/include/micro-os-plus/micro-test-plus/test-runner.h +281 -0
- package/include/micro-os-plus/micro-test-plus/test-suite.h +492 -0
- package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
- package/include/micro-os-plus/micro-test-plus.h +172 -552
- package/meson.build +7 -5
- package/package.json +29 -34
- package/src/micro-test-plus.cpp +134 -37
- package/src/test-reporter-basic.cpp +466 -0
- package/src/test-reporter-tap.cpp +530 -0
- package/src/test-reporter.cpp +207 -240
- package/src/test-runner.cpp +135 -23
- package/src/test-suite.cpp +182 -10
- 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,514 @@
|
|
|
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++ operators.
|
|
21
|
+
*
|
|
22
|
+
* @details
|
|
23
|
+
* This header provides the declarations for the custom operator overloads used
|
|
24
|
+
* within the µTest++ framework. It defines interfaces for equality,
|
|
25
|
+
* inequality, relational, and logical operators tailored for use with the
|
|
26
|
+
* framework’s strongly-typed constants, wrappers, containers, and string
|
|
27
|
+
* views.
|
|
28
|
+
*
|
|
29
|
+
* These operator overloads enable expressive, concise, and type-safe test
|
|
30
|
+
* assertions, supporting both compile-time and run-time evaluation. The
|
|
31
|
+
* operators are selectively enabled for types recognised by the framework,
|
|
32
|
+
* minimising the risk of conflicts with user-defined or standard operators.
|
|
33
|
+
*
|
|
34
|
+
* All definitions reside within the
|
|
35
|
+
* `micro_os_plus::micro_test_plus::operators` namespace, ensuring clear
|
|
36
|
+
* separation from user code and minimising the risk of naming conflicts.
|
|
37
|
+
*
|
|
38
|
+
* The header files are organised within the
|
|
39
|
+
* `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
|
|
40
|
+
* modular codebase.
|
|
41
|
+
*
|
|
42
|
+
* This file is intended solely for internal use within the framework and
|
|
43
|
+
* should not be included directly by user code.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
#ifndef MICRO_TEST_PLUS_OPERATORS_H_
|
|
47
|
+
#define MICRO_TEST_PLUS_OPERATORS_H_
|
|
48
|
+
|
|
49
|
+
// ----------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
#ifdef __cplusplus
|
|
52
|
+
|
|
53
|
+
// ----------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
#include <string_view>
|
|
56
|
+
|
|
57
|
+
#include "detail.h"
|
|
58
|
+
|
|
59
|
+
// ----------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
#if defined(__GNUC__)
|
|
62
|
+
#pragma GCC diagnostic push
|
|
63
|
+
#pragma GCC diagnostic ignored "-Wpadded"
|
|
64
|
+
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
65
|
+
#if defined(__clang__)
|
|
66
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
67
|
+
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
|
68
|
+
#endif
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
namespace micro_os_plus::micro_test_plus
|
|
72
|
+
{
|
|
73
|
+
// --------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @namespace micro_os_plus::micro_test_plus::operators
|
|
77
|
+
* @brief Custom operator overloads for expressive and type-safe test
|
|
78
|
+
* assertions.
|
|
79
|
+
*
|
|
80
|
+
* @details
|
|
81
|
+
* The `micro_os_plus::micro_test_plus::operators` namespace provides a
|
|
82
|
+
* comprehensive set of custom operator overloads designed to enable
|
|
83
|
+
* expressive, concise, and type-safe test assertions within the µTest++
|
|
84
|
+
* framework.
|
|
85
|
+
*
|
|
86
|
+
* This namespace includes equality, inequality, relational, and logical
|
|
87
|
+
* operators tailored for use with the framework’s custom types, containers,
|
|
88
|
+
* and string views. These operators facilitate the creation of clear and
|
|
89
|
+
* readable test expressions, supporting both strongly-typed constants (via
|
|
90
|
+
* user-defined literals) and dynamic values (via wrappers).
|
|
91
|
+
*
|
|
92
|
+
* @warning Please be aware that these operators
|
|
93
|
+
* may conflict with other operators defined within the application under
|
|
94
|
+
* test.
|
|
95
|
+
*
|
|
96
|
+
* To minimise conflicts with application-defined operators, these overloads
|
|
97
|
+
* are enabled only for specific types recognised by the framework, such as
|
|
98
|
+
* those derived from the local `op` base type or identified as containers or
|
|
99
|
+
* string views. Constants typically require a literal suffix (e.g., `1_i`),
|
|
100
|
+
* while dynamic values should be wrapped using the provided casting
|
|
101
|
+
* utilities (e.g., `mt::to_i{...}`).
|
|
102
|
+
*
|
|
103
|
+
* All definitions within this namespace are implemented in the
|
|
104
|
+
* `include/micro-os-plus/micro-test-plus` folder, ensuring a modular and
|
|
105
|
+
* maintainable codebase.
|
|
106
|
+
*/
|
|
107
|
+
namespace operators
|
|
108
|
+
{
|
|
109
|
+
// In order to simplify things and use the return type `auto`,
|
|
110
|
+
// the definition must be included before any use.
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @ingroup micro-test-plus-string-operators
|
|
114
|
+
* @brief Equality operator for `string_view` objects.
|
|
115
|
+
*
|
|
116
|
+
* @param [in] lhs The left hand side `std::string_view` operand.
|
|
117
|
+
* @param [in] rhs The right hand side `std::string_view` operand.
|
|
118
|
+
* @return A comparator object that evaluates to true if the string views
|
|
119
|
+
* are equal.
|
|
120
|
+
*
|
|
121
|
+
* @details
|
|
122
|
+
* This overload of the equality operator enables direct comparison of two
|
|
123
|
+
* `std::string_view` objects within the µTest++ framework. It constructs a
|
|
124
|
+
* comparator object that can be used in test expectations and assertions
|
|
125
|
+
* to verify that two string views are equal.
|
|
126
|
+
*/
|
|
127
|
+
[[nodiscard]] constexpr auto
|
|
128
|
+
operator== (std::string_view lhs, std::string_view rhs)
|
|
129
|
+
{
|
|
130
|
+
return detail::eq_{ lhs, rhs };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @ingroup micro-test-plus-string-operators
|
|
135
|
+
* @brief Non-equality operator for `string_view` objects.
|
|
136
|
+
*
|
|
137
|
+
* @param [in] lhs The left hand side `std::string_view` operand.
|
|
138
|
+
* @param [in] rhs The right hand side `std::string_view` operand.
|
|
139
|
+
* @return A comparator object that evaluates to true if the string views
|
|
140
|
+
* are not equal.
|
|
141
|
+
*
|
|
142
|
+
* @details
|
|
143
|
+
* This overload of the non-equality operator enables direct comparison of
|
|
144
|
+
* two `std::string_view` objects within the µTest++ framework. It
|
|
145
|
+
* constructs a comparator object that can be used in test expectations and
|
|
146
|
+
* assertions to verify that two string views are not equal.
|
|
147
|
+
*/
|
|
148
|
+
[[nodiscard]] constexpr auto
|
|
149
|
+
operator!= (std::string_view lhs, std::string_view rhs)
|
|
150
|
+
{
|
|
151
|
+
return detail::ne_{ lhs, rhs };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @ingroup micro-test-plus-container-operators
|
|
156
|
+
* @brief Equality operator for containers.
|
|
157
|
+
*
|
|
158
|
+
* @tparam T The container type, constrained to recognised container types.
|
|
159
|
+
*
|
|
160
|
+
* @param [in] lhs The left hand side container operand.
|
|
161
|
+
* @param [in] rhs The right hand side container operand.
|
|
162
|
+
* @return A comparator object that evaluates to true if the containers are
|
|
163
|
+
* equal.
|
|
164
|
+
*
|
|
165
|
+
* @details
|
|
166
|
+
* This overload of the equality operator enables direct comparison of two
|
|
167
|
+
* container objects within the µTest++ framework. It constructs a
|
|
168
|
+
* comparator object that can be used in test expectations and assertions
|
|
169
|
+
* to verify that two containers are equal in content and order.
|
|
170
|
+
*
|
|
171
|
+
* The operator is enabled only for types recognised as containers by the
|
|
172
|
+
* framework's type traits.
|
|
173
|
+
*/
|
|
174
|
+
template <class T,
|
|
175
|
+
type_traits::requires_t<type_traits::is_container_v<T>> = 0>
|
|
176
|
+
[[nodiscard]] constexpr auto
|
|
177
|
+
operator== (T&& lhs, T&& rhs)
|
|
178
|
+
{
|
|
179
|
+
return detail::eq_{ static_cast<T&&> (lhs), static_cast<T&&> (rhs) };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @ingroup micro-test-plus-container-operators
|
|
184
|
+
* @brief Non-equality operator for containers.
|
|
185
|
+
*
|
|
186
|
+
* @tparam T The container type, constrained to recognised container types.
|
|
187
|
+
*
|
|
188
|
+
* @param [in] lhs The left hand side container operand.
|
|
189
|
+
* @param [in] rhs The right hand side container operand.
|
|
190
|
+
* @return A comparator object that evaluates to true if the containers are
|
|
191
|
+
* not equal.
|
|
192
|
+
*
|
|
193
|
+
* @details
|
|
194
|
+
* This overload of the non-equality operator enables direct comparison of
|
|
195
|
+
* two container objects within the µTest++ framework. It constructs a
|
|
196
|
+
* comparator object that can be used in test expectations and assertions
|
|
197
|
+
* to verify that two containers are not equal in content or order.
|
|
198
|
+
*
|
|
199
|
+
* The operator is enabled only for types recognised as containers by the
|
|
200
|
+
* framework's type traits.
|
|
201
|
+
*/
|
|
202
|
+
template <class T,
|
|
203
|
+
type_traits::requires_t<type_traits::is_container_v<T>> = 0>
|
|
204
|
+
[[nodiscard]] constexpr auto
|
|
205
|
+
operator!= (T&& lhs, T&& rhs)
|
|
206
|
+
{
|
|
207
|
+
return detail::ne_{ static_cast<T&&> (lhs), static_cast<T&&> (rhs) };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @ingroup micro-test-plus-operators
|
|
212
|
+
* @brief Equality operator for custom types. Matches only if at least one
|
|
213
|
+
* operand is of local type.
|
|
214
|
+
*
|
|
215
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
216
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
217
|
+
*
|
|
218
|
+
* @param [in] lhs Left hand side operand.
|
|
219
|
+
* @param [in] rhs Right hand side operand.
|
|
220
|
+
* @return A comparator object that evaluates to true if the operands are
|
|
221
|
+
* equal.
|
|
222
|
+
*
|
|
223
|
+
* @details
|
|
224
|
+
* This overload of the equality operator enables comparison between two
|
|
225
|
+
* operands, where at least one is a local type derived from the local `op`
|
|
226
|
+
* base. It constructs a comparator object that can be used within the
|
|
227
|
+
* µTest++ framework to assert that the operands are equal. This operator
|
|
228
|
+
* is intended for use with the framework's strongly-typed constants,
|
|
229
|
+
* wrappers, or other custom types, ensuring type-safe and expressive test
|
|
230
|
+
* assertions.
|
|
231
|
+
*/
|
|
232
|
+
template <class Lhs_T, class Rhs_T,
|
|
233
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
234
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
235
|
+
= 0>
|
|
236
|
+
[[nodiscard]] constexpr auto
|
|
237
|
+
operator== (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
238
|
+
{
|
|
239
|
+
return detail::eq_{ lhs, rhs };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @ingroup micro-test-plus-operators
|
|
244
|
+
* @brief Non-equality operator for custom types. Matches only if at least
|
|
245
|
+
* one operand is of local type.
|
|
246
|
+
*
|
|
247
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
248
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
249
|
+
*
|
|
250
|
+
* @param [in] lhs Left hand side operand.
|
|
251
|
+
* @param [in] rhs Right hand side operand.
|
|
252
|
+
* @return A comparator object that evaluates to true if the operands are
|
|
253
|
+
* not equal.
|
|
254
|
+
*
|
|
255
|
+
* @details
|
|
256
|
+
* This overload of the non-equality operator enables comparison between
|
|
257
|
+
* two operands, where at least one is a local type derived from the local
|
|
258
|
+
* `op` base. It constructs a comparator object that can be used within the
|
|
259
|
+
* µTest++ framework to assert that the operands are not equal. This
|
|
260
|
+
* operator is intended for use with the framework's strongly-typed
|
|
261
|
+
* constants, wrappers, or other custom types, ensuring type-safe and
|
|
262
|
+
* expressive test assertions.
|
|
263
|
+
*/
|
|
264
|
+
template <class Lhs_T, class Rhs_T,
|
|
265
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
266
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
267
|
+
= 0>
|
|
268
|
+
[[nodiscard]] constexpr auto
|
|
269
|
+
operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
270
|
+
{
|
|
271
|
+
return detail::ne_{ lhs, rhs };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @ingroup micro-test-plus-operators
|
|
276
|
+
* @brief Greater than operator. Matches only if at least one operand is of
|
|
277
|
+
* local type (derived from local `op`).
|
|
278
|
+
*
|
|
279
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
280
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
281
|
+
*
|
|
282
|
+
* @param [in] lhs Left hand side operand.
|
|
283
|
+
* @param [in] rhs Right hand side operand.
|
|
284
|
+
* @return A comparator object that evaluates to true if the left hand side
|
|
285
|
+
* operand is greater than the right hand side operand.
|
|
286
|
+
*
|
|
287
|
+
* @details
|
|
288
|
+
* This overload of the greater than operator enables comparison between
|
|
289
|
+
* two operands, where at least one is a local type derived from the local
|
|
290
|
+
* `op` base. It constructs a comparator object that can be used within the
|
|
291
|
+
* µTest++ framework to assert that the left hand side operand is greater
|
|
292
|
+
* than the right hand side operand. This operator is intended for use with
|
|
293
|
+
* the framework's strongly-typed constants, wrappers, or other custom
|
|
294
|
+
* types, ensuring type-safe and expressive test assertions.
|
|
295
|
+
*/
|
|
296
|
+
template <class Lhs_T, class Rhs_T,
|
|
297
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
298
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
299
|
+
= 0>
|
|
300
|
+
[[nodiscard]] constexpr auto
|
|
301
|
+
operator> (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
302
|
+
{
|
|
303
|
+
return detail::gt_{ lhs, rhs };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @ingroup micro-test-plus-operators
|
|
308
|
+
* @brief Greater than or equal operator. Matches only if at least one
|
|
309
|
+
* operand is of local type (derived from local `op`).
|
|
310
|
+
*
|
|
311
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
312
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
313
|
+
*
|
|
314
|
+
* @param [in] lhs Left hand side operand.
|
|
315
|
+
* @param [in] rhs Right hand side operand.
|
|
316
|
+
* @return A comparator object that evaluates to true if the left hand side
|
|
317
|
+
* operand is greater than or equal to the right hand side operand.
|
|
318
|
+
*
|
|
319
|
+
* @details
|
|
320
|
+
* This overload of the greater than or equal operator enables comparison
|
|
321
|
+
* between two operands, where at least one is a local type derived from
|
|
322
|
+
* the local `op` base. It constructs a comparator object that can be used
|
|
323
|
+
* within the µTest++ framework to assert that the left hand side operand
|
|
324
|
+
* is greater than or equal to the right hand side operand. This operator
|
|
325
|
+
* is intended for use with the framework's strongly-typed constants,
|
|
326
|
+
* wrappers, or other custom types, ensuring type-safe and expressive test
|
|
327
|
+
* assertions.
|
|
328
|
+
*/
|
|
329
|
+
template <class Lhs_T, class Rhs_T,
|
|
330
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
331
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
332
|
+
= 0>
|
|
333
|
+
[[nodiscard]] constexpr auto
|
|
334
|
+
operator>= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
335
|
+
{
|
|
336
|
+
return detail::ge_{ lhs, rhs };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @ingroup micro-test-plus-operators
|
|
341
|
+
* @brief Less than operator. Matches only if at least one operand is of
|
|
342
|
+
* local type (derived from local `op`).
|
|
343
|
+
*
|
|
344
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
345
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
346
|
+
*
|
|
347
|
+
* @param [in] lhs Left hand side operand.
|
|
348
|
+
* @param [in] rhs Right hand side operand.
|
|
349
|
+
* @return A comparator object that evaluates to true if the left hand side
|
|
350
|
+
* operand is less than the right hand side operand.
|
|
351
|
+
*
|
|
352
|
+
* @details
|
|
353
|
+
* This overload of the less than operator enables comparison between two
|
|
354
|
+
* operands, where at least one is a local type derived from the local `op`
|
|
355
|
+
* base. It constructs a comparator object that can be used within the
|
|
356
|
+
* µTest++ framework to assert that the left hand side operand is less than
|
|
357
|
+
* the right hand side operand. This operator is intended for use with the
|
|
358
|
+
* framework's strongly-typed constants, wrappers, or other custom types,
|
|
359
|
+
* ensuring type-safe and expressive test assertions.
|
|
360
|
+
*/
|
|
361
|
+
template <class Lhs_T, class Rhs_T,
|
|
362
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
363
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
364
|
+
= 0>
|
|
365
|
+
[[nodiscard]] constexpr auto
|
|
366
|
+
operator< (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
367
|
+
{
|
|
368
|
+
return detail::lt_{ lhs, rhs };
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @ingroup micro-test-plus-operators
|
|
373
|
+
* @brief Less than or equal operator. Matches only if at least one operand
|
|
374
|
+
* is of local type (derived from local `op`).
|
|
375
|
+
*
|
|
376
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
377
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
378
|
+
*
|
|
379
|
+
* @param [in] lhs Left hand side operand.
|
|
380
|
+
* @param [in] rhs Right hand side operand.
|
|
381
|
+
* @return A comparator object that evaluates to true if the left hand side
|
|
382
|
+
* operand is less than or equal to the right hand side operand.
|
|
383
|
+
*
|
|
384
|
+
* @details
|
|
385
|
+
* This overload of the less than or equal operator enables comparison
|
|
386
|
+
* between two operands, where at least one is a local type derived from
|
|
387
|
+
* the local `op` base. It constructs a comparator object that can be used
|
|
388
|
+
* within the µTest++ framework to assert that the left hand side operand
|
|
389
|
+
* is less than or equal to the right hand side operand. This operator is
|
|
390
|
+
* intended for use with the framework's strongly-typed constants,
|
|
391
|
+
* wrappers, or other custom types, ensuring type-safe and expressive test
|
|
392
|
+
* assertions.
|
|
393
|
+
*/
|
|
394
|
+
template <class Lhs_T, class Rhs_T,
|
|
395
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
396
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
397
|
+
= 0>
|
|
398
|
+
[[nodiscard]] constexpr auto
|
|
399
|
+
operator<= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
400
|
+
{
|
|
401
|
+
return detail::le_{ lhs, rhs };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @ingroup micro-test-plus-operators
|
|
406
|
+
* @brief Logical `&&` (and) operator. Matches only if at least one operand
|
|
407
|
+
* is of local type (derived from local `op`).
|
|
408
|
+
*
|
|
409
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
410
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
411
|
+
*
|
|
412
|
+
* @param [in] lhs Left hand side operand.
|
|
413
|
+
* @param [in] rhs Right hand side operand.
|
|
414
|
+
* @return A logical conjunction object that evaluates to true if both
|
|
415
|
+
* operands are true.
|
|
416
|
+
*
|
|
417
|
+
* @details
|
|
418
|
+
* This overload of the logical `&&` (and) operator enables conjunction
|
|
419
|
+
* between two operands, where at least one is a local type derived from
|
|
420
|
+
* the local `op` base. It constructs a logical conjunction object that can
|
|
421
|
+
* be used within the µTest++ framework to assert that both operands
|
|
422
|
+
* evaluate to true. This operator is intended for use with the framework's
|
|
423
|
+
* strongly-typed constants, wrappers, or other custom types, ensuring
|
|
424
|
+
* type-safe and expressive test assertions.
|
|
425
|
+
*/
|
|
426
|
+
template <class Lhs_T, class Rhs_T,
|
|
427
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
428
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
429
|
+
= 0>
|
|
430
|
+
[[nodiscard]] constexpr auto
|
|
431
|
+
operator and (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
432
|
+
{
|
|
433
|
+
return detail::and_{ lhs, rhs };
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* @ingroup micro-test-plus-operators
|
|
438
|
+
* @brief Logical `||` (or) operator. Matches only if at least one operand
|
|
439
|
+
* is of local type (derived from local `op`).
|
|
440
|
+
*
|
|
441
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
442
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
443
|
+
*
|
|
444
|
+
* @param [in] lhs Left hand side operand.
|
|
445
|
+
* @param [in] rhs Right hand side operand.
|
|
446
|
+
* @return A logical disjunction object that evaluates to true if at least
|
|
447
|
+
* one operand is true.
|
|
448
|
+
*
|
|
449
|
+
* @details
|
|
450
|
+
* This overload of the logical `||` (or) operator enables disjunction
|
|
451
|
+
* between two operands, where at least one is a local type derived from
|
|
452
|
+
* the local `op` base. It constructs a logical disjunction object that can
|
|
453
|
+
* be used within the µTest++ framework to assert that at least one operand
|
|
454
|
+
* evaluates to true. This operator is intended for use with the
|
|
455
|
+
* framework's strongly-typed constants, wrappers, or other custom types,
|
|
456
|
+
* ensuring type-safe and expressive test assertions.
|
|
457
|
+
*/
|
|
458
|
+
template <class Lhs_T, class Rhs_T,
|
|
459
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
460
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
461
|
+
= 0>
|
|
462
|
+
[[nodiscard]] constexpr auto
|
|
463
|
+
operator or (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
464
|
+
{
|
|
465
|
+
return detail::or_{ lhs, rhs };
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @ingroup micro-test-plus-operators
|
|
470
|
+
* @brief Logical `!` (not) operator. Matches only if the operand is of
|
|
471
|
+
* local type (derived from local `op`).
|
|
472
|
+
*
|
|
473
|
+
* @tparam T Type of the operand, constrained to types derived from the
|
|
474
|
+
* local `op` base.
|
|
475
|
+
*
|
|
476
|
+
* @param [in] t Operand to be logically negated.
|
|
477
|
+
* @return A logical negator object that evaluates to true if the operand
|
|
478
|
+
* is false.
|
|
479
|
+
*
|
|
480
|
+
* @details
|
|
481
|
+
* This overload of the logical `!` (not) operator enables logical negation
|
|
482
|
+
* of an operand, provided it is a local type derived from the local `op`
|
|
483
|
+
* base. It constructs a logical negator object that can be used within the
|
|
484
|
+
* µTest++ framework to assert that a given condition is false. This
|
|
485
|
+
* operator is intended for use with the framework's strongly-typed
|
|
486
|
+
* constants, wrappers, or other custom types, ensuring type-safe and
|
|
487
|
+
* expressive test assertions.
|
|
488
|
+
*/
|
|
489
|
+
template <class T, type_traits::requires_t<type_traits::is_op_v<T>> = 0>
|
|
490
|
+
[[nodiscard]] constexpr auto
|
|
491
|
+
operator not(const T& t)
|
|
492
|
+
{
|
|
493
|
+
return detail::not_{ t };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// ------------------------------------------------------------------------
|
|
497
|
+
} // namespace operators
|
|
498
|
+
|
|
499
|
+
// --------------------------------------------------------------------------
|
|
500
|
+
} // namespace micro_os_plus::micro_test_plus
|
|
501
|
+
|
|
502
|
+
#if defined(__GNUC__)
|
|
503
|
+
#pragma GCC diagnostic pop
|
|
504
|
+
#endif
|
|
505
|
+
|
|
506
|
+
// ----------------------------------------------------------------------------
|
|
507
|
+
|
|
508
|
+
#endif // __cplusplus
|
|
509
|
+
|
|
510
|
+
// ----------------------------------------------------------------------------
|
|
511
|
+
|
|
512
|
+
#endif // MICRO_TEST_PLUS_OPERATORS_H_
|
|
513
|
+
|
|
514
|
+
// ----------------------------------------------------------------------------
|