micro-test-plus
4.1.0
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
operators-inlines.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
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
49
#include "
micro-os-plus/micro-test-plus/detail.h
"
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
63
namespace
micro_os_plus::micro_test_plus
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>
103
requires
(
type_traits::container_like<Lhs_T>
104
and
type_traits::container_like<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>
121
requires
(
type_traits::container_like<Lhs_T>
122
and
type_traits::container_like<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>
136
requires
type_traits::any_op<Lhs_T, 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>
150
requires
type_traits::any_op<Lhs_T, 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>
164
requires
type_traits::any_op<Lhs_T, 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>
179
requires
type_traits::any_op<Lhs_T, 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>
193
requires
type_traits::any_op<Lhs_T, 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>
208
requires
type_traits::any_op<Lhs_T, 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>
222
requires
type_traits::any_op<Lhs_T, 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>
236
requires
type_traits::any_op<Lhs_T, 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>
250
requires
type_traits::is_op<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
// ----------------------------------------------------------------------------
micro_os_plus::micro_test_plus::type_traits::any_op
C++20 concept satisfied when at least one of two types derives from op.
Definition
type-traits.h:454
micro_os_plus::micro_test_plus::type_traits::container_like
C++20 concept satisfied when T provides both begin() and end() member functions.
Definition
type-traits.h:363
micro_os_plus::micro_test_plus::type_traits::is_op
C++20 concept satisfied when a type derives from op.
Definition
type-traits.h:437
detail.h
C++ header file with declarations for the µTest++ internals.
micro_os_plus::micro_test_plus::operators::operator<=
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...
Definition
operators-inlines.h:210
micro_os_plus::micro_test_plus::operators::operator<
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).
Definition
operators-inlines.h:195
micro_os_plus::micro_test_plus::operators::operator>=
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...
Definition
operators-inlines.h:181
micro_os_plus::micro_test_plus::operators::operator>
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).
Definition
operators-inlines.h:166
micro_os_plus::micro_test_plus::operators::operator!=
constexpr auto operator!=(std::string_view lhs, std::string_view rhs)
Non-equality operator for string_view objects.
Definition
operators-inlines.h:88
micro_os_plus::micro_test_plus::operators::operator==
constexpr auto operator==(std::string_view lhs, std::string_view rhs)
Equality operator for string_view objects.
Definition
operators-inlines.h:76
micro_os_plus::micro_test_plus::operators
Custom operator overloads for expressive and type-safe test assertions.
Definition
operators-inlines.h:66
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
micro_os_plus::micro_test_plus::detail::and_
Logical AND comparator struct template.
Definition
detail.h:503
micro_os_plus::micro_test_plus::detail::eq_
Equality comparator struct template.
Definition
detail.h:306
micro_os_plus::micro_test_plus::detail::ge_
Greater than or equal comparator struct template.
Definition
detail.h:403
micro_os_plus::micro_test_plus::detail::gt_
Greater than comparator struct template.
Definition
detail.h:370
micro_os_plus::micro_test_plus::detail::le_
Less than or equal comparator struct template.
Definition
detail.h:469
micro_os_plus::micro_test_plus::detail::lt_
Less than comparator struct template.
Definition
detail.h:436
micro_os_plus::micro_test_plus::detail::ne_
Non-equality comparator struct template.
Definition
detail.h:338
micro_os_plus::micro_test_plus::detail::not_
Logical NOT comparator struct template.
Definition
detail.h:567
micro_os_plus::micro_test_plus::detail::or_
Logical OR comparator struct template.
Definition
detail.h:536
include
micro-os-plus
micro-test-plus
inlines
operators-inlines.h
Generated by
1.17.0