micro-test-plus 3.3.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
test-reporter.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
43
44// ----------------------------------------------------------------------------
45
46#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
47#include <micro-os-plus/config.h>
48#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
49
51
52// ----------------------------------------------------------------------------
53
54#pragma GCC diagnostic ignored "-Waggregate-return"
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wunknown-warning-option"
57#pragma clang diagnostic ignored "-Wc++98-compat"
58#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
59#endif
60
62{
63 // --------------------------------------------------------------------------
64
66
67 // --------------------------------------------------------------------------
68
79 {
80 reporter->endline ();
81 return stream;
82 }
83
95 {
96 // Call the endl function.
97 (*func) (*this);
98 return *this;
99 }
100
110 test_reporter::operator<< (std::string_view sv)
111 {
112 out_.append (sv);
113 return *this;
114 }
115
125 {
126 out_.append (1, c);
127 return *this;
128 }
129
139 test_reporter::operator<< (const char* s)
140 {
141 out_.append (s);
142 return *this;
143 }
144
155 {
156 out_.append (s);
157 return *this;
158 }
159
170 {
171 out_.append (v ? "true" : "false");
172 return *this;
173 }
174
183 test_reporter::operator<< (std::nullptr_t)
184 {
185 out_.append ("nullptr");
186 return *this;
187 }
188
198 test_reporter::operator<< (signed char c)
199 {
200 out_.append (std::to_string (c));
201 out_.append ("c");
202 return *this;
203 }
204
214 test_reporter::operator<< (unsigned char c)
215 {
216 out_.append (std::to_string (static_cast<int> (c)));
217 out_.append ("uc");
218 return *this;
219 }
220
230 test_reporter::operator<< (signed short v)
231 {
232 out_.append (std::to_string (v));
233 out_.append ("s");
234 return *this;
235 }
236
246 test_reporter::operator<< (unsigned short v)
247 {
248 out_.append (std::to_string (static_cast<long> (v)));
249 out_.append ("us");
250 return *this;
251 }
252
262 test_reporter::operator<< (signed int v)
263 {
264 out_.append (std::to_string (v));
265 return *this;
266 }
267
277 test_reporter::operator<< (unsigned int v)
278 {
279 out_.append (std::to_string (v));
280 out_.append ("u");
281 return *this;
282 }
283
293 test_reporter::operator<< (signed long v)
294 {
295 out_.append (std::to_string (v));
296 out_.append ("l");
297 return *this;
298 }
299
309 test_reporter::operator<< (unsigned long v)
310 {
311 out_.append (std::to_string (v));
312 out_.append ("ul");
313 return *this;
314 }
315
325 test_reporter::operator<< (signed long long v)
326 {
327 out_.append (std::to_string (v));
328 out_.append ("ll");
329 return *this;
330 }
331
341 test_reporter::operator<< (unsigned long long v)
342 {
343 out_.append (std::to_string (v));
344 out_.append ("ull");
345 return *this;
346 }
347
358 {
359 out_.append (std::to_string (v));
360 out_.append ("f");
361 return *this;
362 }
363
374 {
375 out_.append (std::to_string (v));
376 return *this;
377 }
378
389 test_reporter::operator<< (long double v)
390 {
391 out_.append (std::to_string (v));
392 out_.append ("l");
393 return *this;
394 }
395
396 // --------------------------------------------------------------------------
397} // namespace micro_os_plus::micro_test_plus
398
399// ----------------------------------------------------------------------------
Reporter to display test results, including operand values and types for failures.
std::string out_
Internal output buffer for accumulating report content.
virtual ~test_reporter()
Default constructor for the test_reporter class.
test_reporter & operator<<(std::string_view sv)
Output operator for std::string_view.
Main C++ header with the declarations for the µTest++ Testing Framework.
Primary namespace for the µTest++ testing framework.
test_reporter * reporter
Global pointer to test_reporter.
test_reporter & endl(test_reporter &stream)
Output stream manipulator for ending a line in test reports.