Skip to main content

The function-comparators.h File Reference

C++ header file with declarations 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 declarations for the µTest++ function comparators.

This header provides the declarations for the function comparator templates and logical operators used within the µTest++ framework. It defines the interfaces for generic and pointer-based comparison functions, including equality, non-equality, greater than, less than, and their respective logical variants. Additionally, it declares 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 and provide clear, readable test expressions.

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
49
50#ifndef MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
51#define MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
52
53// ----------------------------------------------------------------------------
54
55#ifdef __cplusplus
56
57// ----------------------------------------------------------------------------
58
59#if defined(__GNUC__)
60#pragma GCC diagnostic push
61#pragma GCC diagnostic ignored "-Wpadded"
62#pragma GCC diagnostic ignored "-Waggregate-return"
63#if defined(__clang__)
64#pragma clang diagnostic ignored "-Wc++98-compat"
65#pragma clang diagnostic ignored "-Wunknown-warning-option"
66#endif
67#endif
68
70{
71 // --------------------------------------------------------------------------
72
84 template <class Lhs_T, class Rhs_T>
85 [[nodiscard]] constexpr auto
86 eq (const Lhs_T& lhs, const Rhs_T& rhs);
87
99 template <class Lhs_T, class Rhs_T>
100 [[nodiscard]] constexpr auto
101 eq (Lhs_T* lhs, Rhs_T* rhs);
102
114 template <class Lhs_T, class Rhs_T>
115 [[nodiscard]] constexpr auto
116 ne (const Lhs_T& lhs, const Rhs_T& rhs);
117
130 template <class Lhs_T, class Rhs_T>
131 [[nodiscard]] constexpr auto
132 ne (Lhs_T* lhs, Rhs_T* rhs);
133
145 template <class Lhs_T, class Rhs_T>
146 [[nodiscard]] constexpr auto
147 gt (const Lhs_T& lhs, const Rhs_T& rhs);
148
160 template <class Lhs_T, class Rhs_T>
161 [[nodiscard]] constexpr auto
162 gt (Lhs_T* lhs, Rhs_T* rhs);
163
176 template <class Lhs_T, class Rhs_T>
177 [[nodiscard]] constexpr auto
178 ge (const Lhs_T& lhs, const Rhs_T& rhs);
179
192 template <class Lhs_T, class Rhs_T>
193 [[nodiscard]] constexpr auto
194 ge (Lhs_T* lhs, Rhs_T* rhs);
195
208 template <class Lhs_T, class Rhs_T>
209 [[nodiscard]] constexpr auto
210 lt (const Lhs_T& lhs, const Rhs_T& rhs);
211
224 template <class Lhs_T, class Rhs_T>
225 [[nodiscard]] constexpr auto
226 lt (Lhs_T* lhs, Rhs_T* rhs);
227
240 template <class Lhs_T, class Rhs_T>
241 [[nodiscard]] constexpr auto
242 le (const Lhs_T& lhs, const Rhs_T& rhs);
243
256 template <class Lhs_T, class Rhs_T>
257 [[nodiscard]] constexpr auto
258 le (Lhs_T* lhs, Rhs_T* rhs);
259
269 template <class Expr_T>
270 [[nodiscard]] constexpr auto
271 _not (const Expr_T& expr);
272
285 template <class Lhs_T, class Rhs_T>
286 [[nodiscard]] constexpr auto
287 _and (const Lhs_T& lhs, const Rhs_T& rhs);
288
301 template <class Lhs_T, class Rhs_T>
302 [[nodiscard]] constexpr auto
303 _or (const Lhs_T& lhs, const Rhs_T& rhs);
304
314 template <class T>
315 [[nodiscard]] constexpr auto
316 mut (const T& t) noexcept -> T&;
317
318#if defined(__GNUC__)
319#pragma GCC diagnostic pop
320#endif
321
322 // --------------------------------------------------------------------------
323} // namespace micro_os_plus::micro_test_plus
324
325// ----------------------------------------------------------------------------
326
327#endif // __cplusplus
328
329// ----------------------------------------------------------------------------
330
331#endif // MICRO_TEST_PLUS_FUNCTION_COMPARATORS_H_
332
333// ----------------------------------------------------------------------------

Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.