Skip to main content

function-comparators-inlines.h File

C++ header file with inline implementations for the µTest++ function comparators. More...

Namespaces Index​

namespacemicro_os_plus

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

namespacemicro_test_plus

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

Functions Index​

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

Generic logical and operation. More...

template <class Expr_T>
constexpr auto_not (const Expr_T &expr)

Generic logical not operation. More...

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

Generic logical or operation. More...

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

Generic equality comparator for non-pointer types. More...

template <class Lhs_T, class Rhs_T>
constexpr autoeq (Lhs_T *lhs, Rhs_T *rhs)

Pointer equality comparator for any pointer types. More...

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

Generic greater than or equal comparator. More...

template <class Lhs_T, class Rhs_T>
constexpr autoge (Lhs_T *lhs, Rhs_T *rhs)

Pointer greater than or equal comparator. More...

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

Generic greater than comparator. More...

template <class Lhs_T, class Rhs_T>
constexpr autogt (Lhs_T *lhs, Rhs_T *rhs)

Pointer greater than comparator. More...

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

Generic less than or equal comparator. More...

template <class Lhs_T, class Rhs_T>
constexpr autole (Lhs_T *lhs, Rhs_T *rhs)

Pointer less than or equal comparator. More...

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

Generic less than comparator. More...

template <class Lhs_T, class Rhs_T>
constexpr autolt (Lhs_T *lhs, Rhs_T *rhs)

Pointer less than comparator. More...

template <class T>
constexpr T &mut (const T &t) noexcept

Generic mutator to remove const qualification from any type. More...

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

Generic non-equality comparator. More...

template <class Lhs_T, class Rhs_T>
constexpr autone (Lhs_T *lhs, Rhs_T *rhs)

Pointer non-equality comparator. More...

Description​

C++ header file with inline implementations for the µTest++ function comparators.

This header provides the inline implementations for the function comparator templates used within the µTest++ framework. It defines the logic for generic and pointer-based comparison operators, including equality, non-equality, greater than, less than, and their respective logical variants. Additionally, it implements logical combinators such as conjunction (_and), disjunction (_or), and negation (_not), as well as a utility for safely removing constness from objects.

These comparators and logical operators enable expressive and type-safe test expectations and assertions, supporting both value and pointer semantics. The underscore-prefixed logical operators are intentionally named to avoid conflicts with standard operators.

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

The header files are organised within the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

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
48
49#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_FUNCTION_COMPARATORS_INLINES_H_
50#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_FUNCTION_COMPARATORS_INLINES_H_
51
52// ----------------------------------------------------------------------------
53
54#if defined(__cplusplus)
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic push
60
61#pragma GCC diagnostic ignored "-Waggregate-return"
62#if defined(__clang__)
63#pragma clang diagnostic ignored "-Wc++98-compat"
64#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
65#endif // defined(__clang__)
66#endif // defined(__GNUC__)
67
68// ============================================================================
69
71{
72 // --------------------------------------------------------------------------
73
82 template <class Lhs_T, class Rhs_T>
83 constexpr auto
84 eq (const Lhs_T& lhs, const Rhs_T& rhs)
85 {
86 return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
87 }
88
97 template <class Lhs_T, class Rhs_T>
98 constexpr auto
99 eq (Lhs_T* lhs, Rhs_T* rhs)
100 {
101 return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
102 }
103
112 template <class Lhs_T, class Rhs_T>
113 constexpr auto
114 ne (const Lhs_T& lhs, const Rhs_T& rhs)
115 {
116 return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
117 }
118
127 template <class Lhs_T, class Rhs_T>
128 constexpr auto
129 ne (Lhs_T* lhs, Rhs_T* rhs)
130 {
131 return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
132 }
133
142 template <class Lhs_T, class Rhs_T>
143 constexpr auto
144 gt (const Lhs_T& lhs, const Rhs_T& rhs)
145 {
146 return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
147 }
148
157 template <class Lhs_T, class Rhs_T>
158 constexpr auto
159 gt (Lhs_T* lhs, Rhs_T* rhs)
160 {
161 return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
162 }
163
172 template <class Lhs_T, class Rhs_T>
173 constexpr auto
174 ge (const Lhs_T& lhs, const Rhs_T& rhs)
175 {
176 return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
177 }
178
188 template <class Lhs_T, class Rhs_T>
189 constexpr auto
190 ge (Lhs_T* lhs, Rhs_T* rhs)
191 {
192 return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
193 }
194
203 template <class Lhs_T, class Rhs_T>
204 constexpr auto
205 lt (const Lhs_T& lhs, const Rhs_T& rhs)
206 {
207 return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
208 }
209
218 template <class Lhs_T, class Rhs_T>
219 constexpr auto
220 lt (Lhs_T* lhs, Rhs_T* rhs)
221 {
222 return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
223 }
224
233 template <class Lhs_T, class Rhs_T>
234 constexpr auto
235 le (const Lhs_T& lhs, const Rhs_T& rhs)
236 {
237 return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
238 }
239
249 template <class Lhs_T, class Rhs_T>
250 constexpr auto
251 le (Lhs_T* lhs, Rhs_T* rhs)
252 {
253 return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
254 }
255
256 // --------------------------------------------------------------------------
257 // Logical operators.
258
270 template <class Expr_T>
271 constexpr auto
272 _not (const Expr_T& expr)
273 {
274 return detail::not_<Expr_T>{ expr };
275 }
276
288 template <class Lhs_T, class Rhs_T>
289 constexpr auto
290 _and (const Lhs_T& lhs, const Rhs_T& rhs)
291 {
292 return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
293 }
294
306 template <class Lhs_T, class Rhs_T>
307 constexpr auto
308 _or (const Lhs_T& lhs, const Rhs_T& rhs)
309 {
310 return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
311 }
312
313 // --------------------------------------------------------------------------
314 // Utility functions.
315
324 template <class T>
325 constexpr auto
326 mut (const T& t) noexcept -> T&
327 {
328 return const_cast<T&> (t);
329 }
330
331 // --------------------------------------------------------------------------
332} // namespace micro_os_plus::micro_test_plus
333
334#if defined(__GNUC__)
335#pragma GCC diagnostic pop
336#endif // defined(__GNUC__)
337
338// ----------------------------------------------------------------------------
339
340#endif // defined(__cplusplus)
341
342// ----------------------------------------------------------------------------
343
344#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_FUNCTION_COMPARATORS_INLINES_H_
345
346// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.