micro-test-plus 6.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
55
56#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
57#define MICRO_OS_PLUS_MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
58
59// ----------------------------------------------------------------------------
60
61#if defined(__cplusplus)
62
63// ----------------------------------------------------------------------------
64
65#if __has_include("micro-os-plus/project-config.h")
66#include "micro-os-plus/project-config.h"
67#endif // __has_include("micro-os-plus/project-config.h")
68
69#if __has_include("micro-os-plus/micro-test-plus-defines.h")
70#include "micro-os-plus/micro-test-plus-defines.h"
71#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
72
73#include "detail.h"
74
75// ----------------------------------------------------------------------------
76
77#if defined(__GNUC__)
78#pragma GCC diagnostic push
79
80#pragma GCC diagnostic ignored "-Wpadded"
81#pragma GCC diagnostic ignored "-Waggregate-return"
82#if defined(__clang__)
83#pragma clang diagnostic ignored "-Wc++98-compat"
84#pragma clang diagnostic ignored "-Wpre-c++17-compat"
85#pragma clang diagnostic ignored "-Wunknown-warning-option"
86#endif // defined(__clang__)
87#endif // defined(__GNUC__)
88
89// ===========================================================================
90
92{
93 // --------------------------------------------------------------------------
94
130 template <class Lhs_T, class Rhs_T>
132 Rhs_T>
133 [[nodiscard]] constexpr auto
134 eq (Lhs_T&& lhs, Rhs_T&& rhs);
135
136#if !defined(__DOXYGEN__)
153 template <class Lhs_T, class Rhs_T>
155 Rhs_T>)
156 [[nodiscard]] constexpr bool
157 eq (Lhs_T&& lhs, Rhs_T&& rhs);
158#endif // !defined(__DOXYGEN__)
159
171 template <class Lhs_T, class Rhs_T>
173 Rhs_T>
174 [[nodiscard]] constexpr auto
175 ne (Lhs_T&& lhs, Rhs_T&& rhs);
176
177#if !defined(__DOXYGEN__)
194 template <class Lhs_T, class Rhs_T>
196 Lhs_T, Rhs_T>)
197 [[nodiscard]] constexpr bool
198 ne (Lhs_T&& lhs, Rhs_T&& rhs);
199#endif // !defined(__DOXYGEN__)
200
212 template <class Lhs_T, class Rhs_T>
214 Rhs_T>
215 [[nodiscard]] constexpr auto
216 gt (Lhs_T&& lhs, Rhs_T&& rhs);
217
218#if !defined(__DOXYGEN__)
235 template <class Lhs_T, class Rhs_T>
237 Lhs_T, Rhs_T>)
238 [[nodiscard]] constexpr bool
239 gt (Lhs_T&& lhs, Rhs_T&& rhs);
240#endif // !defined(__DOXYGEN__)
241
254 template <class Lhs_T, class Rhs_T>
256 Lhs_T, Rhs_T>
257 [[nodiscard]] constexpr auto
258 ge (Lhs_T&& lhs, Rhs_T&& rhs);
259
260#if !defined(__DOXYGEN__)
277 template <class Lhs_T, class Rhs_T>
278 requires (not detail::comparable_operands<
280 [[nodiscard]] constexpr bool
281 ge (Lhs_T&& lhs, Rhs_T&& rhs);
282#endif // !defined(__DOXYGEN__)
283
296 template <class Lhs_T, class Rhs_T>
298 Rhs_T>
299 [[nodiscard]] constexpr auto
300 lt (Lhs_T&& lhs, Rhs_T&& rhs);
301
302#if !defined(__DOXYGEN__)
319 template <class Lhs_T, class Rhs_T>
321 Rhs_T>)
322 [[nodiscard]] constexpr bool
323 lt (Lhs_T&& lhs, Rhs_T&& rhs);
324#endif // !defined(__DOXYGEN__)
325
338 template <class Lhs_T, class Rhs_T>
340 Rhs_T>
341 [[nodiscard]] constexpr auto
342 le (Lhs_T&& lhs, Rhs_T&& rhs);
343
344#if !defined(__DOXYGEN__)
361 template <class Lhs_T, class Rhs_T>
363 Lhs_T, Rhs_T>)
364 [[nodiscard]] constexpr bool
365 le (Lhs_T&& lhs, Rhs_T&& rhs);
366#endif // !defined(__DOXYGEN__)
367
406 template <class Lhs_T, class Rhs_T, class Epsilon_T>
410 [[nodiscard]] constexpr auto
411 approx (Lhs_T&& lhs, Rhs_T&& rhs, Epsilon_T&& epsilon);
412
426 template <class Expr_T>
428 [[nodiscard]] constexpr auto
429 negate (Expr_T&& expr);
430
448 template <class First_T, class Second_T, class... Rest_T>
451 and (extension::checkable<std::remove_cvref_t<Rest_T>> and ...))
452 [[nodiscard]] constexpr auto
453 all_of (First_T&& first, Second_T&& second, Rest_T&&... rest);
454
473 template <class First_T, class Second_T, class... Rest_T>
476 and (extension::checkable<std::remove_cvref_t<Rest_T>> and ...))
477 [[nodiscard]] constexpr auto
478 any_of (First_T&& first, Second_T&& second, Rest_T&&... rest);
479
480 // --------------------------------------------------------------------------
481} // namespace micro_os_plus::micro_test_plus
482
483#if defined(__GNUC__)
484#pragma GCC diagnostic pop
485#endif // defined(__GNUC__)
486
487// ----------------------------------------------------------------------------
488
489#endif // defined(__cplusplus)
490
491// ============================================================================
492// Templates, inlines & constexpr implementations.
493
495
496// ----------------------------------------------------------------------------
497
498#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
499
500// ----------------------------------------------------------------------------
Concept satisfied when the operands of a comparator can be written and compared.
Concept satisfied when T is a valid operand of the approximate comparator.
Definition detail.h:1968
Concept satisfied when a type can be used as a test expression in expect() or require().
Definition extension.h:403
C++ header file with declarations for the µTest++ internals.
C++ header file with inline implementations for the µTest++ function comparators.
constexpr auto approx(T value, std::type_identity_t< T > epsilon) noexcept -> detail::value< T >
Deprecated wrapping of a floating-point value with an explicit comparison tolerance.
constexpr auto eq(Lhs_T &&lhs, Rhs_T &&rhs)
Generic equality comparator.
constexpr auto lt(Lhs_T &&lhs, Rhs_T &&rhs)
Generic less than comparator.
constexpr auto ge(Lhs_T &&lhs, Rhs_T &&rhs)
Generic greater than or equal comparator.
constexpr auto gt(Lhs_T &&lhs, Rhs_T &&rhs)
Generic greater than comparator.
constexpr auto le(Lhs_T &&lhs, Rhs_T &&rhs)
Generic less than or equal comparator.
constexpr auto ne(Lhs_T &&lhs, Rhs_T &&rhs)
Generic non-equality comparator.
constexpr auto all_of(First_T &&first, Second_T &&second, Rest_T &&... rest)
Generic logical and operation, for two or more operands.
constexpr auto any_of(First_T &&first, Second_T &&second, Rest_T &&... rest)
Generic logical (inclusive) or operation, for two or more operands.
constexpr auto negate(Expr_T &&expr)
Generic logical not operation.
@ greater_equal
The >= operator, checked by ge().
@ less_equal
The <= operator, checked by le().
@ not_equal
The != operator, checked by ne().
Primary namespace for the µTest++ testing framework.