micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
function-comparators.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
49
50#ifndef MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
51#define MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
52
53// ----------------------------------------------------------------------------
54
55#ifdef __cplusplus
56
57// ----------------------------------------------------------------------------
58
59#if defined(__GNUC__)
60#pragma GCC diagnostic push
61#pragma GCC diagnostic ignored "-Wpadded"
62#pragma GCC diagnostic ignored "-Waggregate-return"
63#if defined(__clang__)
64#pragma clang diagnostic ignored "-Wc++98-compat"
65#pragma clang diagnostic ignored "-Wpre-c++17-compat"
66#pragma clang diagnostic ignored "-Wunknown-warning-option"
67#endif
68#endif
69
70// ===========================================================================
71
73{
74 // --------------------------------------------------------------------------
75
87 template <class Lhs_T, class Rhs_T>
88 [[nodiscard]] constexpr auto
89 eq (const Lhs_T& lhs, const Rhs_T& rhs);
90
102 template <class Lhs_T, class Rhs_T>
103 [[nodiscard]] constexpr auto
104 eq (Lhs_T* lhs, Rhs_T* rhs);
105
117 template <class Lhs_T, class Rhs_T>
118 [[nodiscard]] constexpr auto
119 ne (const Lhs_T& lhs, const Rhs_T& rhs);
120
133 template <class Lhs_T, class Rhs_T>
134 [[nodiscard]] constexpr auto
135 ne (Lhs_T* lhs, Rhs_T* rhs);
136
148 template <class Lhs_T, class Rhs_T>
149 [[nodiscard]] constexpr auto
150 gt (const Lhs_T& lhs, const Rhs_T& rhs);
151
163 template <class Lhs_T, class Rhs_T>
164 [[nodiscard]] constexpr auto
165 gt (Lhs_T* lhs, Rhs_T* rhs);
166
179 template <class Lhs_T, class Rhs_T>
180 [[nodiscard]] constexpr auto
181 ge (const Lhs_T& lhs, const Rhs_T& rhs);
182
195 template <class Lhs_T, class Rhs_T>
196 [[nodiscard]] constexpr auto
197 ge (Lhs_T* lhs, Rhs_T* rhs);
198
211 template <class Lhs_T, class Rhs_T>
212 [[nodiscard]] constexpr auto
213 lt (const Lhs_T& lhs, const Rhs_T& rhs);
214
227 template <class Lhs_T, class Rhs_T>
228 [[nodiscard]] constexpr auto
229 lt (Lhs_T* lhs, Rhs_T* rhs);
230
243 template <class Lhs_T, class Rhs_T>
244 [[nodiscard]] constexpr auto
245 le (const Lhs_T& lhs, const Rhs_T& rhs);
246
259 template <class Lhs_T, class Rhs_T>
260 [[nodiscard]] constexpr auto
261 le (Lhs_T* lhs, Rhs_T* rhs);
262
272 template <class Expr_T>
273 [[nodiscard]] constexpr auto
274 _not (const Expr_T& expr);
275
288 template <class Lhs_T, class Rhs_T>
289 [[nodiscard]] constexpr auto
290 _and (const Lhs_T& lhs, const Rhs_T& rhs);
291
304 template <class Lhs_T, class Rhs_T>
305 [[nodiscard]] constexpr auto
306 _or (const Lhs_T& lhs, const Rhs_T& rhs);
307
317 template <class T>
318 [[nodiscard]] constexpr auto
319 mut (const T& t) noexcept -> T&;
320
321 // --------------------------------------------------------------------------
322} // namespace micro_os_plus::micro_test_plus
323
324#if defined(__GNUC__)
325#pragma GCC diagnostic pop
326#endif
327
328// ----------------------------------------------------------------------------
329
330#endif // __cplusplus
331
332// ============================================================================
333// Templates & constexpr implementations.
334
336
337// ----------------------------------------------------------------------------
338
339#endif // MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
340
341// ----------------------------------------------------------------------------
C++ header file with inline implementations for the µTest++ function comparators.
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.