micro-test-plus 5.0.0
µTest++ Testing Framework
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
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
65{
66 // --------------------------------------------------------------------------
67
74 expression_formatter::operator<< (std::string_view sv)
75 {
76 buffer_.append (sv);
77 return *this;
78 }
79
87 {
88 buffer_.append (1, c);
89 return *this;
90 }
91
99 {
100 buffer_.append (s);
101 return *this;
102 }
103
111 {
112 buffer_.append (v ? "true" : "false");
113 return *this;
114 }
115
122 {
123 buffer_.append ("nullptr");
124 return *this;
125 }
126
134 {
136 buffer_.append ("c");
137 return *this;
138 }
139
146 expression_formatter::operator<< (unsigned char c)
147 {
149 buffer_.append ("uc");
150 return *this;
151 }
152
160 {
162 buffer_.append ("s");
163 return *this;
164 }
165
172 expression_formatter::operator<< (unsigned short v)
173 {
175 buffer_.append ("us");
176 return *this;
177 }
178
186 {
188 return *this;
189 }
190
198 {
200 buffer_.append ("u");
201 return *this;
202 }
203
211 {
213 buffer_.append ("l");
214 return *this;
215 }
216
223 expression_formatter::operator<< (unsigned long v)
224 {
226 buffer_.append ("ul");
227 return *this;
228 }
229
236 expression_formatter::operator<< (signed long long v)
237 {
239 buffer_.append ("ll");
240 return *this;
241 }
242
249 expression_formatter::operator<< (unsigned long long v)
250 {
252 buffer_.append ("ull");
253 return *this;
254 }
255
263 {
265 buffer_.append ("f");
266 return *this;
267 }
268
276 {
278 return *this;
279 }
280
288 {
290 buffer_.append ("l");
291 return *this;
292 }
293
294 // --------------------------------------------------------------------------
295} // namespace micro_os_plus::micro_test_plus::detail
296
297// ----------------------------------------------------------------------------
expression_formatter & operator<<(std::string_view sv)
Appends a string view to the buffer.
expression_formatter(colours &colours) noexcept
Constructor with colour configuration.
C++ header file with declarations for the µTest++ expression formatter.
Internal implementation details for the µTest++ framework.
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-...