micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
function-comparators-inlines.h
Go to the documentation of this file.
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
48
49#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_FUNCTION_COMPARATORS_INLINES_H_
50#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_FUNCTION_COMPARATORS_INLINES_H_
51
52// ----------------------------------------------------------------------------
53
54#if defined(__cplusplus)
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic push
60
61#pragma GCC diagnostic ignored "-Waggregate-return"
62#if defined(__clang__)
63#pragma clang diagnostic ignored "-Wc++98-compat"
64#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
65#endif // defined(__clang__)
66#endif // defined(__GNUC__)
67
68// ============================================================================
69
71{
72 // --------------------------------------------------------------------------
73
82 template <class Lhs_T, class Rhs_T>
83 constexpr auto
84 eq (const Lhs_T& lhs, const Rhs_T& rhs)
85 {
86 return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
87 }
88
97 template <class Lhs_T, class Rhs_T>
98 constexpr auto
99 eq (Lhs_T* lhs, Rhs_T* rhs)
100 {
101 return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
102 }
103
112 template <class Lhs_T, class Rhs_T>
113 constexpr auto
114 ne (const Lhs_T& lhs, const Rhs_T& rhs)
115 {
116 return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
117 }
118
127 template <class Lhs_T, class Rhs_T>
128 constexpr auto
129 ne (Lhs_T* lhs, Rhs_T* rhs)
130 {
131 return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
132 }
133
142 template <class Lhs_T, class Rhs_T>
143 constexpr auto
144 gt (const Lhs_T& lhs, const Rhs_T& rhs)
145 {
146 return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
147 }
148
157 template <class Lhs_T, class Rhs_T>
158 constexpr auto
159 gt (Lhs_T* lhs, Rhs_T* rhs)
160 {
161 return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
162 }
163
172 template <class Lhs_T, class Rhs_T>
173 constexpr auto
174 ge (const Lhs_T& lhs, const Rhs_T& rhs)
175 {
176 return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
177 }
178
188 template <class Lhs_T, class Rhs_T>
189 constexpr auto
190 ge (Lhs_T* lhs, Rhs_T* rhs)
191 {
192 return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
193 }
194
203 template <class Lhs_T, class Rhs_T>
204 constexpr auto
205 lt (const Lhs_T& lhs, const Rhs_T& rhs)
206 {
207 return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
208 }
209
218 template <class Lhs_T, class Rhs_T>
219 constexpr auto
220 lt (Lhs_T* lhs, Rhs_T* rhs)
221 {
222 return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
223 }
224
233 template <class Lhs_T, class Rhs_T>
234 constexpr auto
235 le (const Lhs_T& lhs, const Rhs_T& rhs)
236 {
237 return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
238 }
239
249 template <class Lhs_T, class Rhs_T>
250 constexpr auto
251 le (Lhs_T* lhs, Rhs_T* rhs)
252 {
253 return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
254 }
255
256 // --------------------------------------------------------------------------
257 // Logical operators.
258
270 template <class Expr_T>
271 constexpr auto
272 _not (const Expr_T& expr)
273 {
274 return detail::not_<Expr_T>{ expr };
275 }
276
288 template <class Lhs_T, class Rhs_T>
289 constexpr auto
290 _and (const Lhs_T& lhs, const Rhs_T& rhs)
291 {
292 return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
293 }
294
306 template <class Lhs_T, class Rhs_T>
307 constexpr auto
308 _or (const Lhs_T& lhs, const Rhs_T& rhs)
309 {
310 return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
311 }
312
313 // --------------------------------------------------------------------------
314 // Utility functions.
315
324 template <class T>
325 constexpr auto
326 mut (const T& t) noexcept -> T&
327 {
328 return const_cast<T&> (t);
329 }
330
331 // --------------------------------------------------------------------------
332} // namespace micro_os_plus::micro_test_plus
333
334#if defined(__GNUC__)
335#pragma GCC diagnostic pop
336#endif // defined(__GNUC__)
337
338// ----------------------------------------------------------------------------
339
340#endif // defined(__cplusplus)
341
342// ----------------------------------------------------------------------------
343
344#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_FUNCTION_COMPARATORS_INLINES_H_
345
346// ----------------------------------------------------------------------------
constexpr auto le(const Lhs_T &lhs, const Rhs_T &rhs)
Generic less than or equal comparator.
constexpr auto ge(const Lhs_T &lhs, const Rhs_T &rhs)
Generic greater than or equal comparator.
constexpr auto ne(const Lhs_T &lhs, const Rhs_T &rhs)
Generic non-equality comparator.
constexpr auto lt(const Lhs_T &lhs, const Rhs_T &rhs)
Generic less than comparator.
constexpr auto gt(const Lhs_T &lhs, const Rhs_T &rhs)
Generic greater than comparator.
constexpr auto eq(const Lhs_T &lhs, const Rhs_T &rhs)
Generic equality comparator for non-pointer types.
constexpr auto _and(const Lhs_T &lhs, const Rhs_T &rhs)
Generic logical and operation.
constexpr auto _or(const Lhs_T &lhs, const Rhs_T &rhs)
Generic logical or operation.
constexpr auto _not(const Expr_T &expr)
Generic logical not operation.
constexpr auto mut(const T &t) noexcept -> T &
Generic mutator to remove const qualification from any type.
Primary namespace for the µTest++ testing framework.
Logical AND comparator struct template.
Definition detail.h:512
Equality comparator struct template.
Definition detail.h:315
Greater than or equal comparator struct template.
Definition detail.h:412
Greater than comparator struct template.
Definition detail.h:379
Less than or equal comparator struct template.
Definition detail.h:478
Less than comparator struct template.
Definition detail.h:445
Non-equality comparator struct template.
Definition detail.h:347
Logical NOT comparator struct template.
Definition detail.h:576
Logical OR comparator struct template.
Definition detail.h:545