micro-test-plus 5.0.1
µ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_OS_PLUS_MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
51#define MICRO_OS_PLUS_MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
52
53// ----------------------------------------------------------------------------
54
55#if defined(__cplusplus)
56
57// ----------------------------------------------------------------------------
58
59#if __has_include("micro-os-plus/project-config.h")
60#include "micro-os-plus/project-config.h"
61#endif // __has_include("micro-os-plus/project-config.h")
62
63#if __has_include("micro-os-plus/micro-test-plus-defines.h")
64#include "micro-os-plus/micro-test-plus-defines.h"
65#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
66
67// ----------------------------------------------------------------------------
68
69#if defined(__GNUC__)
70#pragma GCC diagnostic push
71
72#pragma GCC diagnostic ignored "-Wpadded"
73#pragma GCC diagnostic ignored "-Waggregate-return"
74#if defined(__clang__)
75#pragma clang diagnostic ignored "-Wc++98-compat"
76#pragma clang diagnostic ignored "-Wpre-c++17-compat"
77#pragma clang diagnostic ignored "-Wunknown-warning-option"
78#endif // defined(__clang__)
79#endif // defined(__GNUC__)
80
81// ===========================================================================
82
84{
85 // --------------------------------------------------------------------------
86
98 template <class Lhs_T, class Rhs_T>
99 [[nodiscard]] constexpr auto
100 eq (const Lhs_T& lhs, const Rhs_T& rhs);
101
113 template <class Lhs_T, class Rhs_T>
114 [[nodiscard]] constexpr auto
115 eq (Lhs_T* lhs, Rhs_T* rhs);
116
128 template <class Lhs_T, class Rhs_T>
129 [[nodiscard]] constexpr auto
130 ne (const Lhs_T& lhs, const Rhs_T& rhs);
131
144 template <class Lhs_T, class Rhs_T>
145 [[nodiscard]] constexpr auto
146 ne (Lhs_T* lhs, Rhs_T* rhs);
147
159 template <class Lhs_T, class Rhs_T>
160 [[nodiscard]] constexpr auto
161 gt (const Lhs_T& lhs, const Rhs_T& rhs);
162
174 template <class Lhs_T, class Rhs_T>
175 [[nodiscard]] constexpr auto
176 gt (Lhs_T* lhs, Rhs_T* rhs);
177
190 template <class Lhs_T, class Rhs_T>
191 [[nodiscard]] constexpr auto
192 ge (const Lhs_T& lhs, const Rhs_T& rhs);
193
206 template <class Lhs_T, class Rhs_T>
207 [[nodiscard]] constexpr auto
208 ge (Lhs_T* lhs, Rhs_T* rhs);
209
222 template <class Lhs_T, class Rhs_T>
223 [[nodiscard]] constexpr auto
224 lt (const Lhs_T& lhs, const Rhs_T& rhs);
225
238 template <class Lhs_T, class Rhs_T>
239 [[nodiscard]] constexpr auto
240 lt (Lhs_T* lhs, Rhs_T* rhs);
241
254 template <class Lhs_T, class Rhs_T>
255 [[nodiscard]] constexpr auto
256 le (const Lhs_T& lhs, const Rhs_T& rhs);
257
270 template <class Lhs_T, class Rhs_T>
271 [[nodiscard]] constexpr auto
272 le (Lhs_T* lhs, Rhs_T* rhs);
273
283 template <class Expr_T>
284 [[nodiscard]] constexpr auto
285 _not (const Expr_T& expr);
286
299 template <class Lhs_T, class Rhs_T>
300 [[nodiscard]] constexpr auto
301 _and (const Lhs_T& lhs, const Rhs_T& rhs);
302
315 template <class Lhs_T, class Rhs_T>
316 [[nodiscard]] constexpr auto
317 _or (const Lhs_T& lhs, const Rhs_T& rhs);
318
328 template <class T>
329 [[nodiscard]] constexpr auto
330 mut (const T& t) noexcept -> T&;
331
332 // --------------------------------------------------------------------------
333} // namespace micro_os_plus::micro_test_plus
334
335#if defined(__GNUC__)
336#pragma GCC diagnostic pop
337#endif // defined(__GNUC__)
338
339// ----------------------------------------------------------------------------
340
341#endif // defined(__cplusplus)
342
343// ============================================================================
344// Templates, inlines & constexpr implementations.
345
347
348// ----------------------------------------------------------------------------
349
350#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
351
352// ----------------------------------------------------------------------------
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.