Skip to main content

operators-inlines.h File

C++ header file with inline implementations for the µTest++ operator overloads. More...

Included Headers

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespaceoperators

Custom operator overloads for expressive and type-safe test assertions. More...

Operators Index

template <class Lhs_T, class Rhs_T>
constexpr autooperator and (const Lhs_T &lhs, const Rhs_T &rhs)

Logical && (and) operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class T>
constexpr autooperator not (const T &t)

Logical ! (not) operator. Matches only if the operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator or (const Lhs_T &lhs, const Rhs_T &rhs)

Logical || (or) operator. Matches only if at least one operand is of local type (derived from local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator!= (const Lhs_T &lhs, const Rhs_T &rhs)

Non-equality operator for custom types. Matches only if at least one operand is of local type. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator!= (const Lhs_T &lhs, const Rhs_T &rhs)

Non-equality operator for containers. More...

constexpr autooperator!= (std::string_view lhs, std::string_view rhs)

Non-equality operator for string_view objects. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator< (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). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator<= (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 local op). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator== (const Lhs_T &lhs, const Rhs_T &rhs)

Equality operator for custom types. Matches only if at least one operand is of local type. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator== (const Lhs_T &lhs, const Rhs_T &rhs)

Equality operator for containers. More...

constexpr autooperator== (std::string_view lhs, std::string_view rhs)

Equality operator for string_view objects. More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator> (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). More...

template <class Lhs_T, class Rhs_T>
constexpr autooperator>= (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 local op). More...

Description

C++ header file with inline implementations for the µTest++ operator overloads.

This header provides the inline implementations for all operator overloads declared in operators.h. Each operator constructs and returns the appropriate comparator or logical object from the detail namespace.

Separating the implementations from the declarations keeps operators.h concise and focused on the interface, whilst grouping all operator bodies here for maintainability.

All definitions reside within the micro_os_plus::micro_test_plus::operators namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

This file is intended solely for internal use within the framework and should not be included directly by user code.

File Listing

The file content with the documentation metadata removed is:

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 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
39
40#ifndef MICRO_TEST_PLUS_OPERATORS_INLINES_H_
41#define MICRO_TEST_PLUS_OPERATORS_INLINES_H_
42
43// ----------------------------------------------------------------------------
44
45#ifdef __cplusplus
46
47// ----------------------------------------------------------------------------
48
50
51// ----------------------------------------------------------------------------
52
53#if defined(__GNUC__)
54#pragma GCC diagnostic push
55#pragma GCC diagnostic ignored "-Waggregate-return"
56#if defined(__clang__)
57#pragma clang diagnostic ignored "-Wc++98-compat"
58#endif
59#endif
60
61// ============================================================================
62
64{
65 namespace operators
66 {
67 // ========================================================================
68
75 constexpr auto
76 operator==(std::string_view lhs, std::string_view rhs)
77 {
78 return detail::eq_{ lhs, rhs };
79 }
80
87 constexpr auto
88 operator!=(std::string_view lhs, std::string_view rhs)
89 {
90 return detail::ne_{ lhs, rhs };
91 }
92
102 template <class Lhs_T, class Rhs_T>
105 constexpr auto
106 operator== (const Lhs_T& lhs, const Rhs_T& rhs)
107 {
108 return detail::eq_{ lhs, rhs };
109 }
110
120 template <class Lhs_T, class Rhs_T>
123 constexpr auto
124 operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
125 {
126 return detail::ne_{ lhs, rhs };
127 }
128
135 template <class Lhs_T, class Rhs_T>
137 constexpr auto
138 operator==(const Lhs_T& lhs, const Rhs_T& rhs)
139 {
140 return detail::eq_{ lhs, rhs };
141 }
142
149 template <class Lhs_T, class Rhs_T>
151 constexpr auto
152 operator!=(const Lhs_T& lhs, const Rhs_T& rhs)
153 {
154 return detail::ne_{ lhs, rhs };
155 }
156
163 template <class Lhs_T, class Rhs_T>
165 constexpr auto
166 operator>(const Lhs_T& lhs, const Rhs_T& rhs)
167 {
168 return detail::gt_{ lhs, rhs };
169 }
170
178 template <class Lhs_T, class Rhs_T>
180 constexpr auto
181 operator>=(const Lhs_T& lhs, const Rhs_T& rhs)
182 {
183 return detail::ge_{ lhs, rhs };
184 }
185
192 template <class Lhs_T, class Rhs_T>
194 constexpr auto
195 operator<(const Lhs_T& lhs, const Rhs_T& rhs)
196 {
197 return detail::lt_{ lhs, rhs };
198 }
199
207 template <class Lhs_T, class Rhs_T>
209 constexpr auto
210 operator<=(const Lhs_T& lhs, const Rhs_T& rhs)
211 {
212 return detail::le_{ lhs, rhs };
213 }
214
221 template <class Lhs_T, class Rhs_T>
223 constexpr auto
224 operator and (const Lhs_T& lhs, const Rhs_T& rhs)
225 {
226 return detail::and_{ lhs, rhs };
227 }
228
235 template <class Lhs_T, class Rhs_T>
237 constexpr auto
238 operator or (const Lhs_T& lhs, const Rhs_T& rhs)
239 {
240 return detail::or_{ lhs, rhs };
241 }
242
249 template <class T>
251 constexpr auto
252 operator not(const T& t)
253 {
254 return detail::not_{ t };
255 }
256
257 // ------------------------------------------------------------------------
258 } // namespace operators
259
260 // --------------------------------------------------------------------------
261} // namespace micro_os_plus::micro_test_plus
262
263#if defined(__GNUC__)
264#pragma GCC diagnostic pop
265#endif
266
267// ----------------------------------------------------------------------------
268
269#endif // __cplusplus
270
271// ----------------------------------------------------------------------------
272
273#endif // MICRO_TEST_PLUS_OPERATORS_INLINES_H_
274
275// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.