Skip to main content

The function-comparators-inlines.h File Reference

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_os_plus::micro_test_plus

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

Functions Index

constexpr auto_and (const Lhs_T &lhs, const Rhs_T &rhs)

Generic logical and operation. More...

constexpr auto_not (const Expr_T &expr)

Generic logical not operation. More...

constexpr auto_or (const Lhs_T &lhs, const Rhs_T &rhs)

Generic logical or operation. More...

constexpr autoeq (const Lhs_T &lhs, const Rhs_T &rhs)

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

constexpr autoeq (Lhs_T *lhs, Rhs_T *rhs)

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

constexpr autoge (const Lhs_T &lhs, const Rhs_T &rhs)

Generic greater than or equal comparator. More...

constexpr autoge (Lhs_T *lhs, Rhs_T *rhs)

Pointer greater than or equal comparator. More...

constexpr autogt (const Lhs_T &lhs, const Rhs_T &rhs)

Generic greater than comparator. More...

constexpr autogt (Lhs_T *lhs, Rhs_T *rhs)

Pointer greater than comparator. More...

constexpr autole (const Lhs_T &lhs, const Rhs_T &rhs)

Generic less than or equal comparator. More...

constexpr autole (Lhs_T *lhs, Rhs_T *rhs)

Pointer less than or equal comparator. More...

constexpr autolt (const Lhs_T &lhs, const Rhs_T &rhs)

Generic less than comparator. More...

constexpr autolt (Lhs_T *lhs, Rhs_T *rhs)

Pointer less than comparator. More...

constexpr T &mut (const T &t) noexcept

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

constexpr autone (const Lhs_T &lhs, const Rhs_T &rhs)

Generic non-equality comparator. More...

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 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any 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
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_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
50#define MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
51
52// ----------------------------------------------------------------------------
53
54#ifdef __cplusplus
55
56// ----------------------------------------------------------------------------
57
58// #include "detail.h"
59
60// ----------------------------------------------------------------------------
61
62#if defined(__GNUC__)
63#pragma GCC diagnostic push
64#pragma GCC diagnostic ignored "-Waggregate-return"
65#if defined(__clang__)
66#pragma clang diagnostic ignored "-Wc++98-compat"
67#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
68#endif
69#endif
70
72{
73 // --------------------------------------------------------------------------
74
83 template <class Lhs_T, class Rhs_T>
84 [[nodiscard]] constexpr auto
85 eq (const Lhs_T& lhs, const Rhs_T& rhs)
86 {
87 return detail::eq_<Lhs_T, Rhs_T>{ lhs, rhs };
88 }
89
98 template <class Lhs_T, class Rhs_T>
99 [[nodiscard]] constexpr auto
100 eq (Lhs_T* lhs, Rhs_T* rhs)
101 {
102 return detail::eq_<Lhs_T*, Rhs_T*>{ lhs, rhs };
103 }
104
113 template <class Lhs_T, class Rhs_T>
114 [[nodiscard]] constexpr auto
115 ne (const Lhs_T& lhs, const Rhs_T& rhs)
116 {
117 return detail::ne_<Lhs_T, Rhs_T>{ lhs, rhs };
118 }
119
128 template <class Lhs_T, class Rhs_T>
129 [[nodiscard]] constexpr auto
130 ne (Lhs_T* lhs, Rhs_T* rhs)
131 {
132 return detail::ne_<Lhs_T*, Rhs_T*>{ lhs, rhs };
133 }
134
143 template <class Lhs_T, class Rhs_T>
144 [[nodiscard]] constexpr auto
145 gt (const Lhs_T& lhs, const Rhs_T& rhs)
146 {
147 return detail::gt_<Lhs_T, Rhs_T>{ lhs, rhs };
148 }
149
158 template <class Lhs_T, class Rhs_T>
159 [[nodiscard]] constexpr auto
160 gt (Lhs_T* lhs, Rhs_T* rhs)
161 {
162 return detail::gt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
163 }
164
173 template <class Lhs_T, class Rhs_T>
174 [[nodiscard]] constexpr auto
175 ge (const Lhs_T& lhs, const Rhs_T& rhs)
176 {
177 return detail::ge_<Lhs_T, Rhs_T>{ lhs, rhs };
178 }
179
189 template <class Lhs_T, class Rhs_T>
190 [[nodiscard]] constexpr auto
191 ge (Lhs_T* lhs, Rhs_T* rhs)
192 {
193 return detail::ge_<Lhs_T*, Rhs_T*>{ lhs, rhs };
194 }
195
204 template <class Lhs_T, class Rhs_T>
205 [[nodiscard]] constexpr auto
206 lt (const Lhs_T& lhs, const Rhs_T& rhs)
207 {
208 return detail::lt_<Lhs_T, Rhs_T>{ lhs, rhs };
209 }
210
219 template <class Lhs_T, class Rhs_T>
220 [[nodiscard]] constexpr auto
221 lt (Lhs_T* lhs, Rhs_T* rhs)
222 {
223 return detail::lt_<Lhs_T*, Rhs_T*>{ lhs, rhs };
224 }
225
234 template <class Lhs_T, class Rhs_T>
235 [[nodiscard]] constexpr auto
236 le (const Lhs_T& lhs, const Rhs_T& rhs)
237 {
238 return detail::le_<Lhs_T, Rhs_T>{ lhs, rhs };
239 }
240
250 template <class Lhs_T, class Rhs_T>
251 [[nodiscard]] constexpr auto
252 le (Lhs_T* lhs, Rhs_T* rhs)
253 {
254 return detail::le_<Lhs_T*, Rhs_T*>{ lhs, rhs };
255 }
256
268 template <class Expr_T>
269 [[nodiscard]] constexpr auto
270 _not (const Expr_T& expr)
271 {
272 return detail::not_<Expr_T>{ expr };
273 }
274
286 template <class Lhs_T, class Rhs_T>
287 [[nodiscard]] constexpr auto
288 _and (const Lhs_T& lhs, const Rhs_T& rhs)
289 {
290 return detail::and_<Lhs_T, Rhs_T>{ lhs, rhs };
291 }
292
304 template <class Lhs_T, class Rhs_T>
305 [[nodiscard]] constexpr auto
306 _or (const Lhs_T& lhs, const Rhs_T& rhs)
307 {
308 return detail::or_<Lhs_T, Rhs_T>{ lhs, rhs };
309 }
310
319 template <class T>
320 [[nodiscard]] constexpr auto
321 mut (const T& t) noexcept -> T&
322 {
323 return const_cast<T&> (t);
324 }
325
326 // --------------------------------------------------------------------------
327} // namespace micro_os_plus::micro_test_plus
328
329#if defined(__GNUC__)
330#pragma GCC diagnostic pop
331#endif
332
333// ----------------------------------------------------------------------------
334
335#endif // __cplusplus
336
337// ----------------------------------------------------------------------------
338
339#endif // MICRO_TEST_PLUS_FUNCTION_COMPARATORS_INLINES_H_
340
341// ----------------------------------------------------------------------------

Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.