micro-test-plus 4.1.0
µ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_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
50#define MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
51
52// ----------------------------------------------------------------------------
53
54#ifdef __cplusplus
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic push
60#pragma GCC diagnostic ignored "-Waggregate-return"
61#if defined(__clang__)
62#pragma clang diagnostic ignored "-Wc++98-compat"
63#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
64#endif
65#endif
66
67// ============================================================================
68
70{
71 // --------------------------------------------------------------------------
72
81 template <class Lhs_T, class Rhs_T>
82 constexpr auto
83 eq (const Lhs_T& lhs, const Rhs_T& rhs)
84 {
85 return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
86 }
87
96 template <class Lhs_T, class Rhs_T>
97 constexpr auto
98 eq (Lhs_T* lhs, Rhs_T* rhs)
99 {
100 return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
101 }
102
111 template <class Lhs_T, class Rhs_T>
112 constexpr auto
113 ne (const Lhs_T& lhs, const Rhs_T& rhs)
114 {
115 return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
116 }
117
126 template <class Lhs_T, class Rhs_T>
127 constexpr auto
128 ne (Lhs_T* lhs, Rhs_T* rhs)
129 {
130 return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
131 }
132
141 template <class Lhs_T, class Rhs_T>
142 constexpr auto
143 gt (const Lhs_T& lhs, const Rhs_T& rhs)
144 {
145 return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
146 }
147
156 template <class Lhs_T, class Rhs_T>
157 constexpr auto
158 gt (Lhs_T* lhs, Rhs_T* rhs)
159 {
160 return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
161 }
162
171 template <class Lhs_T, class Rhs_T>
172 constexpr auto
173 ge (const Lhs_T& lhs, const Rhs_T& rhs)
174 {
175 return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
176 }
177
187 template <class Lhs_T, class Rhs_T>
188 constexpr auto
189 ge (Lhs_T* lhs, Rhs_T* rhs)
190 {
191 return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
192 }
193
202 template <class Lhs_T, class Rhs_T>
203 constexpr auto
204 lt (const Lhs_T& lhs, const Rhs_T& rhs)
205 {
206 return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
207 }
208
217 template <class Lhs_T, class Rhs_T>
218 constexpr auto
219 lt (Lhs_T* lhs, Rhs_T* rhs)
220 {
221 return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
222 }
223
232 template <class Lhs_T, class Rhs_T>
233 constexpr auto
234 le (const Lhs_T& lhs, const Rhs_T& rhs)
235 {
236 return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
237 }
238
248 template <class Lhs_T, class Rhs_T>
249 constexpr auto
250 le (Lhs_T* lhs, Rhs_T* rhs)
251 {
252 return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
253 }
254
255 // --------------------------------------------------------------------------
256 // Logical operators.
257
269 template <class Expr_T>
270 constexpr auto
271 _not (const Expr_T& expr)
272 {
273 return detail::not_<Expr_T>{ expr };
274 }
275
287 template <class Lhs_T, class Rhs_T>
288 constexpr auto
289 _and (const Lhs_T& lhs, const Rhs_T& rhs)
290 {
291 return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
292 }
293
305 template <class Lhs_T, class Rhs_T>
306 constexpr auto
307 _or (const Lhs_T& lhs, const Rhs_T& rhs)
308 {
309 return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
310 }
311
312 // --------------------------------------------------------------------------
313 // Utility functions.
314
323 template <class T>
324 constexpr auto
325 mut (const T& t) noexcept -> T&
326 {
327 return const_cast<T&> (t);
328 }
329
330 // --------------------------------------------------------------------------
331} // namespace micro_os_plus::micro_test_plus
332
333#if defined(__GNUC__)
334#pragma GCC diagnostic pop
335#endif
336
337// ----------------------------------------------------------------------------
338
339#endif // __cplusplus
340
341// ----------------------------------------------------------------------------
342
343#endif // MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
344
345// ----------------------------------------------------------------------------
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:503
Equality comparator struct template.
Definition detail.h:306
Greater than or equal comparator struct template.
Definition detail.h:403
Greater than comparator struct template.
Definition detail.h:370
Less than or equal comparator struct template.
Definition detail.h:469
Less than comparator struct template.
Definition detail.h:436
Non-equality comparator struct template.
Definition detail.h:338
Logical NOT comparator struct template.
Definition detail.h:567
Logical OR comparator struct template.
Definition detail.h:536