micro-test-plus 3.2.2
µ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 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any 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
9 * be 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// #include "detail.h"
59
60// ----------------------------------------------------------------------------
61
62#if defined(__GNUC__)
63#pragma GCC diagnostic push
64#pragma GCC diagnostic ignored "-Waggregate-return"
65#if defined(__clang__)
66#pragma clang diagnostic ignored "-Wc++98-compat"
67#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
68#endif
69#endif
70
72{
73 // --------------------------------------------------------------------------
74
83 template <class Lhs_T, class Rhs_T>
84 [[nodiscard]] constexpr auto
85 eq (const Lhs_T& lhs, const Rhs_T& rhs)
86 {
87 return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
88 }
89
98 template <class Lhs_T, class Rhs_T>
99 [[nodiscard]] constexpr auto
100 eq (Lhs_T* lhs, Rhs_T* rhs)
101 {
102 return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
103 }
104
113 template <class Lhs_T, class Rhs_T>
114 [[nodiscard]] constexpr auto
115 ne (const Lhs_T& lhs, const Rhs_T& rhs)
116 {
117 return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
118 }
119
128 template <class Lhs_T, class Rhs_T>
129 [[nodiscard]] constexpr auto
130 ne (Lhs_T* lhs, Rhs_T* rhs)
131 {
132 return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
133 }
134
143 template <class Lhs_T, class Rhs_T>
144 [[nodiscard]] constexpr auto
145 gt (const Lhs_T& lhs, const Rhs_T& rhs)
146 {
147 return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
148 }
149
158 template <class Lhs_T, class Rhs_T>
159 [[nodiscard]] constexpr auto
160 gt (Lhs_T* lhs, Rhs_T* rhs)
161 {
162 return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
163 }
164
173 template <class Lhs_T, class Rhs_T>
174 [[nodiscard]] constexpr auto
175 ge (const Lhs_T& lhs, const Rhs_T& rhs)
176 {
177 return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
178 }
179
189 template <class Lhs_T, class Rhs_T>
190 [[nodiscard]] constexpr auto
191 ge (Lhs_T* lhs, Rhs_T* rhs)
192 {
193 return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
194 }
195
204 template <class Lhs_T, class Rhs_T>
205 [[nodiscard]] constexpr auto
206 lt (const Lhs_T& lhs, const Rhs_T& rhs)
207 {
208 return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
209 }
210
219 template <class Lhs_T, class Rhs_T>
220 [[nodiscard]] constexpr auto
221 lt (Lhs_T* lhs, Rhs_T* rhs)
222 {
223 return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
224 }
225
234 template <class Lhs_T, class Rhs_T>
235 [[nodiscard]] constexpr auto
236 le (const Lhs_T& lhs, const Rhs_T& rhs)
237 {
238 return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
239 }
240
250 template <class Lhs_T, class Rhs_T>
251 [[nodiscard]] constexpr auto
252 le (Lhs_T* lhs, Rhs_T* rhs)
253 {
254 return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
255 }
256
268 template <class Expr_T>
269 [[nodiscard]] constexpr auto
270 _not (const Expr_T& expr)
271 {
272 return detail::not_<Expr_T>{ expr };
273 }
274
286 template <class Lhs_T, class Rhs_T>
287 [[nodiscard]] constexpr auto
288 _and (const Lhs_T& lhs, const Rhs_T& rhs)
289 {
290 return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
291 }
292
304 template <class Lhs_T, class Rhs_T>
305 [[nodiscard]] constexpr auto
306 _or (const Lhs_T& lhs, const Rhs_T& rhs)
307 {
308 return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
309 }
310
319 template <class T>
320 [[nodiscard]] constexpr auto
321 mut (const T& t) noexcept -> T&
322 {
323 return const_cast<T&> (t);
324 }
325
326 // --------------------------------------------------------------------------
327} // namespace micro_os_plus::micro_test_plus
328
329#if defined(__GNUC__)
330#pragma GCC diagnostic pop
331#endif
332
333// ----------------------------------------------------------------------------
334
335#endif // __cplusplus
336
337// ----------------------------------------------------------------------------
338
339#endif // MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
340
341// ----------------------------------------------------------------------------
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:1178
Equality comparator struct template.
Definition detail.h:260
Greater than or equal comparator struct template.
Definition detail.h:738
Greater than comparator struct template.
Definition detail.h:593
Less than or equal comparator struct template.
Definition detail.h:1031
Less than comparator struct template.
Definition detail.h:885
Non-equality comparator struct template.
Definition detail.h:432
Logical NOT comparator struct template.
Definition detail.h:1415
Logical OR comparator struct template.
Definition detail.h:1297