micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
operators.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
45
46#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_OPERATORS_H_
47#define MICRO_OS_PLUS_MICRO_TEST_PLUS_OPERATORS_H_
48
49// ----------------------------------------------------------------------------
50
51#if defined(__cplusplus)
52
53// ----------------------------------------------------------------------------
54
55#if __has_include("micro-os-plus/project-config.h")
56#include "micro-os-plus/project-config.h"
57#endif // __has_include("micro-os-plus/project-config.h")
58
59#if __has_include("micro-os-plus/micro-test-plus-defines.h")
60#include "micro-os-plus/micro-test-plus-defines.h"
61#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
62
63#include "type-traits.h"
64
65#include <string_view>
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#endif // defined(__clang__)
77#endif // defined(__GNUC__)
78
79// ===========================================================================
80
82{
83 // --------------------------------------------------------------------------
84
117 namespace operators
118 {
128 [[nodiscard]] constexpr auto
129 operator== (std::string_view lhs, std::string_view rhs);
130
140 [[nodiscard]] constexpr auto
141 operator!= (std::string_view lhs, std::string_view rhs);
142
157 template <class Lhs_T, class Rhs_T>
158 requires (type_traits::container_like<Lhs_T>
159 and type_traits::container_like<Rhs_T>)
160 [[nodiscard]] constexpr auto
161 operator== (const Lhs_T& lhs, const Rhs_T& rhs);
162
177 template <class Lhs_T, class Rhs_T>
178 requires (type_traits::container_like<Lhs_T>
179 and type_traits::container_like<Rhs_T>)
180 [[nodiscard]] constexpr auto
181 operator!= (const Lhs_T& lhs, const Rhs_T& rhs);
182
196 template <class Lhs_T, class Rhs_T>
197 requires type_traits::any_op<Lhs_T, Rhs_T>
198 [[nodiscard]] constexpr auto
199 operator== (const Lhs_T& lhs, const Rhs_T& rhs);
200
214 template <class Lhs_T, class Rhs_T>
215 requires type_traits::any_op<Lhs_T, Rhs_T>
216 [[nodiscard]] constexpr auto
217 operator!= (const Lhs_T& lhs, const Rhs_T& rhs);
218
232 template <class Lhs_T, class Rhs_T>
233 requires type_traits::any_op<Lhs_T, Rhs_T>
234 [[nodiscard]] constexpr auto
235 operator> (const Lhs_T& lhs, const Rhs_T& rhs);
236
250 template <class Lhs_T, class Rhs_T>
251 requires type_traits::any_op<Lhs_T, Rhs_T>
252 [[nodiscard]] constexpr auto
253 operator>= (const Lhs_T& lhs, const Rhs_T& rhs);
254
268 template <class Lhs_T, class Rhs_T>
269 requires type_traits::any_op<Lhs_T, Rhs_T>
270 [[nodiscard]] constexpr auto
271 operator< (const Lhs_T& lhs, const Rhs_T& rhs);
272
286 template <class Lhs_T, class Rhs_T>
287 requires type_traits::any_op<Lhs_T, Rhs_T>
288 [[nodiscard]] constexpr auto
289 operator<= (const Lhs_T& lhs, const Rhs_T& rhs);
290
304 template <class Lhs_T, class Rhs_T>
305 requires type_traits::any_op<Lhs_T, Rhs_T>
306 [[nodiscard]] constexpr auto
307 operator and (const Lhs_T& lhs, const Rhs_T& rhs);
308
322 template <class Lhs_T, class Rhs_T>
323 requires type_traits::any_op<Lhs_T, Rhs_T>
324 [[nodiscard]] constexpr auto
325 operator or (const Lhs_T& lhs, const Rhs_T& rhs);
326
339 template <class T>
340 requires type_traits::is_op<T>
341 [[nodiscard]] constexpr auto
342 operator not(const T& t);
343
344 // ------------------------------------------------------------------------
345 } // namespace operators
346
347 // --------------------------------------------------------------------------
348} // namespace micro_os_plus::micro_test_plus
349
350#if defined(__GNUC__)
351#pragma GCC diagnostic pop
352#endif // defined(__GNUC__)
353
354// ----------------------------------------------------------------------------
355
356#endif // defined(__cplusplus)
357
358// ============================================================================
359// Templates, inlines & constexpr implementations.
360
362
363// ----------------------------------------------------------------------------
364
365#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_OPERATORS_H_
366
367// ----------------------------------------------------------------------------
constexpr auto operator<=(const Lhs_T &lhs, const Rhs_T &rhs)
Less than or equal operator. Matches only if at least one operand is of local type (derived from loca...
constexpr auto operator<(const Lhs_T &lhs, const Rhs_T &rhs)
Less than operator. Matches only if at least one operand is of local type (derived from local op).
constexpr auto operator>=(const Lhs_T &lhs, const Rhs_T &rhs)
Greater than or equal operator. Matches only if at least one operand is of local type (derived from l...
constexpr auto operator>(const Lhs_T &lhs, const Rhs_T &rhs)
Greater than operator. Matches only if at least one operand is of local type (derived from local op).
constexpr auto operator!=(std::string_view lhs, std::string_view rhs)
Non-equality operator for string_view objects.
constexpr auto operator==(std::string_view lhs, std::string_view rhs)
Equality operator for string_view objects.
Custom operator overloads for expressive and type-safe test assertions.
Primary namespace for the µTest++ testing framework.
C++ header file with inline implementations for the µTest++ operator overloads.
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.