micro-test-plus
5.0.0
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
expression-formatter.cpp
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
35
36
// ----------------------------------------------------------------------------
37
38
#if __has_include(<micro-os-plus/project-config.h>)
39
#include <micro-os-plus/project-config.h>
40
#elif __has_include(<micro-os-plus/config.h>)
41
#pragma message \
42
"micro-os-plus/config.h is deprecated, rename to micro-os-plus/project-config.h and include it instead of micro-os-plus/config.h"
43
#include <micro-os-plus/config.h>
44
#endif
// __has_include(<micro-os-plus/project-config.h>)
45
46
#if __has_include(<micro-os-plus/micro-test-plus-defines.h>)
47
#include <micro-os-plus/micro-test-plus-defines.h>
48
#endif
// __has_include(<micro-os-plus/micro-test-plus-defines.h>)
49
50
#include "
micro-os-plus/micro-test-plus/expression-formatter.h
"
51
52
// ----------------------------------------------------------------------------
53
54
#if defined(__GNUC__)
55
#pragma GCC diagnostic ignored "-Waggregate-return"
56
#if defined(__clang__)
57
#pragma clang diagnostic ignored "-Wc++98-compat"
58
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
59
#endif
60
#endif
61
62
// ============================================================================
63
64
namespace
micro_os_plus::micro_test_plus::detail
65
{
66
// --------------------------------------------------------------------------
67
73
expression_formatter
&
74
expression_formatter::operator<<
(std::string_view sv)
75
{
76
buffer_
.append (sv);
77
return
*
this
;
78
}
79
85
expression_formatter
&
86
expression_formatter::operator<<
(
char
c)
87
{
88
buffer_
.append (1, c);
89
return
*
this
;
90
}
91
97
expression_formatter
&
98
expression_formatter::operator<<
(
const
char
* s)
99
{
100
buffer_
.append (s);
101
return
*
this
;
102
}
103
109
expression_formatter
&
110
expression_formatter::operator<<
(
bool
v)
111
{
112
buffer_
.append (v ?
"true"
:
"false"
);
113
return
*
this
;
114
}
115
120
expression_formatter
&
121
expression_formatter::operator<<
(std::nullptr_t)
122
{
123
buffer_
.append (
"nullptr"
);
124
return
*
this
;
125
}
126
132
expression_formatter
&
133
expression_formatter::operator<<
(
signed
char
c)
134
{
135
detail::append_number_
(
buffer_
, c);
136
buffer_
.append (
"c"
);
137
return
*
this
;
138
}
139
145
expression_formatter
&
146
expression_formatter::operator<<
(
unsigned
char
c)
147
{
148
detail::append_number_
(
buffer_
, c);
149
buffer_
.append (
"uc"
);
150
return
*
this
;
151
}
152
158
expression_formatter
&
159
expression_formatter::operator<<
(
signed
short
v)
160
{
161
detail::append_number_
(
buffer_
, v);
162
buffer_
.append (
"s"
);
163
return
*
this
;
164
}
165
171
expression_formatter
&
172
expression_formatter::operator<<
(
unsigned
short
v)
173
{
174
detail::append_number_
(
buffer_
, v);
175
buffer_
.append (
"us"
);
176
return
*
this
;
177
}
178
184
expression_formatter
&
185
expression_formatter::operator<<
(
signed
int
v)
186
{
187
detail::append_number_
(
buffer_
, v);
188
return
*
this
;
189
}
190
196
expression_formatter
&
197
expression_formatter::operator<<
(
unsigned
int
v)
198
{
199
detail::append_number_
(
buffer_
, v);
200
buffer_
.append (
"u"
);
201
return
*
this
;
202
}
203
209
expression_formatter
&
210
expression_formatter::operator<<
(
signed
long
v)
211
{
212
detail::append_number_
(
buffer_
, v);
213
buffer_
.append (
"l"
);
214
return
*
this
;
215
}
216
222
expression_formatter
&
223
expression_formatter::operator<<
(
unsigned
long
v)
224
{
225
detail::append_number_
(
buffer_
, v);
226
buffer_
.append (
"ul"
);
227
return
*
this
;
228
}
229
235
expression_formatter
&
236
expression_formatter::operator<<
(
signed
long
long
v)
237
{
238
detail::append_number_
(
buffer_
, v);
239
buffer_
.append (
"ll"
);
240
return
*
this
;
241
}
242
248
expression_formatter
&
249
expression_formatter::operator<<
(
unsigned
long
long
v)
250
{
251
detail::append_number_
(
buffer_
, v);
252
buffer_
.append (
"ull"
);
253
return
*
this
;
254
}
255
261
expression_formatter
&
262
expression_formatter::operator<<
(
float
v)
263
{
264
detail::append_number_
(
buffer_
, v);
265
buffer_
.append (
"f"
);
266
return
*
this
;
267
}
268
274
expression_formatter
&
275
expression_formatter::operator<<
(
double
v)
276
{
277
detail::append_number_
(
buffer_
, v);
278
return
*
this
;
279
}
280
286
expression_formatter
&
287
expression_formatter::operator<<
(
long
double
v)
288
{
289
detail::append_number_
(
buffer_
, v);
290
buffer_
.append (
"l"
);
291
return
*
this
;
292
}
293
294
// --------------------------------------------------------------------------
295
}
// namespace micro_os_plus::micro_test_plus::detail
296
297
// ----------------------------------------------------------------------------
micro_os_plus::micro_test_plus::detail::expression_formatter::buffer_
std::string buffer_
The internal output buffer.
Definition
expression-formatter.h:643
micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<
expression_formatter & operator<<(std::string_view sv)
Appends a string view to the buffer.
Definition
expression-formatter.cpp:74
micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter
expression_formatter(colours &colours) noexcept
Constructor with colour configuration.
Definition
expression-formatter-inlines.h:80
expression-formatter.h
C++ header file with declarations for the µTest++ expression formatter.
micro_os_plus::micro_test_plus::detail
Internal implementation details for the µTest++ framework.
Definition
deferred-reporter.h:79
micro_os_plus::micro_test_plus::detail::append_number_
void append_number_(std::string &buffer, T v)
Appends the string representation of a numeric value to a buffer, using std::to_chars for allocation-...
Definition
detail-inlines.h:654
src
expression-formatter.cpp
Generated by
1.17.0