micro-test-plus
4.1.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 defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
39
#include <micro-os-plus/config.h>
40
#endif
// MICRO_OS_PLUS_INCLUDE_CONFIG_H
41
42
#include "
micro-os-plus/micro-test-plus/expression-formatter.h
"
43
44
// ----------------------------------------------------------------------------
45
46
#if defined(__GNUC__)
47
#pragma GCC diagnostic ignored "-Waggregate-return"
48
#if defined(__clang__)
49
#pragma clang diagnostic ignored "-Wc++98-compat"
50
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
51
#endif
52
#endif
53
54
// ============================================================================
55
56
namespace
micro_os_plus::micro_test_plus::detail
57
{
58
// --------------------------------------------------------------------------
59
65
expression_formatter
&
66
expression_formatter::operator<<
(std::string_view sv)
67
{
68
buffer_
.append (sv);
69
return
*
this
;
70
}
71
77
expression_formatter
&
78
expression_formatter::operator<<
(
char
c)
79
{
80
buffer_
.append (1, c);
81
return
*
this
;
82
}
83
89
expression_formatter
&
90
expression_formatter::operator<<
(
const
char
* s)
91
{
92
buffer_
.append (s);
93
return
*
this
;
94
}
95
101
expression_formatter
&
102
expression_formatter::operator<<
(
bool
v)
103
{
104
buffer_
.append (v ?
"true"
:
"false"
);
105
return
*
this
;
106
}
107
112
expression_formatter
&
113
expression_formatter::operator<<
(std::nullptr_t)
114
{
115
buffer_
.append (
"nullptr"
);
116
return
*
this
;
117
}
118
124
expression_formatter
&
125
expression_formatter::operator<<
(
signed
char
c)
126
{
127
detail::append_number_
(
buffer_
, c);
128
buffer_
.append (
"c"
);
129
return
*
this
;
130
}
131
137
expression_formatter
&
138
expression_formatter::operator<<
(
unsigned
char
c)
139
{
140
detail::append_number_
(
buffer_
, c);
141
buffer_
.append (
"uc"
);
142
return
*
this
;
143
}
144
150
expression_formatter
&
151
expression_formatter::operator<<
(
signed
short
v)
152
{
153
detail::append_number_
(
buffer_
, v);
154
buffer_
.append (
"s"
);
155
return
*
this
;
156
}
157
163
expression_formatter
&
164
expression_formatter::operator<<
(
unsigned
short
v)
165
{
166
detail::append_number_
(
buffer_
, v);
167
buffer_
.append (
"us"
);
168
return
*
this
;
169
}
170
176
expression_formatter
&
177
expression_formatter::operator<<
(
signed
int
v)
178
{
179
detail::append_number_
(
buffer_
, v);
180
return
*
this
;
181
}
182
188
expression_formatter
&
189
expression_formatter::operator<<
(
unsigned
int
v)
190
{
191
detail::append_number_
(
buffer_
, v);
192
buffer_
.append (
"u"
);
193
return
*
this
;
194
}
195
201
expression_formatter
&
202
expression_formatter::operator<<
(
signed
long
v)
203
{
204
detail::append_number_
(
buffer_
, v);
205
buffer_
.append (
"l"
);
206
return
*
this
;
207
}
208
214
expression_formatter
&
215
expression_formatter::operator<<
(
unsigned
long
v)
216
{
217
detail::append_number_
(
buffer_
, v);
218
buffer_
.append (
"ul"
);
219
return
*
this
;
220
}
221
227
expression_formatter
&
228
expression_formatter::operator<<
(
signed
long
long
v)
229
{
230
detail::append_number_
(
buffer_
, v);
231
buffer_
.append (
"ll"
);
232
return
*
this
;
233
}
234
240
expression_formatter
&
241
expression_formatter::operator<<
(
unsigned
long
long
v)
242
{
243
detail::append_number_
(
buffer_
, v);
244
buffer_
.append (
"ull"
);
245
return
*
this
;
246
}
247
253
expression_formatter
&
254
expression_formatter::operator<<
(
float
v)
255
{
256
detail::append_number_
(
buffer_
, v);
257
buffer_
.append (
"f"
);
258
return
*
this
;
259
}
260
266
expression_formatter
&
267
expression_formatter::operator<<
(
double
v)
268
{
269
detail::append_number_
(
buffer_
, v);
270
return
*
this
;
271
}
272
278
expression_formatter
&
279
expression_formatter::operator<<
(
long
double
v)
280
{
281
detail::append_number_
(
buffer_
, v);
282
buffer_
.append (
"l"
);
283
return
*
this
;
284
}
285
286
// --------------------------------------------------------------------------
287
}
// namespace micro_os_plus::micro_test_plus::detail
288
289
// ----------------------------------------------------------------------------
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:66
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:79
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:653
src
expression-formatter.cpp
Generated by
1.17.0