Skip to main content

expression-formatter.cpp File

C++ source file with non-template implementations for the µTest++ expression formatter. More...

Included Headers

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespacedetail

Internal implementation details for the µTest++ framework. More...

Description

C++ source file with non-template implementations for the µTest++ expression formatter.

This source file contains the non-template operator<< overloads of expression_formatter for all standard arithmetic, character, string, boolean, and null-pointer types. Each overload appends the formatted value — together with an appropriate type suffix where applicable — to the internal string buffer.

All definitions reside within the micro_os_plus::micro_test_plus namespace.

This file must be included when building the µTest++ library.

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-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 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
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
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// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.17.0.