Skip to main content

test-reporter.cpp File

C++ source file with implementations for the µTest++ test reporter methods. 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...

Functions Index

test_reporter &endl (test_reporter &stream)

Output stream manipulator for ending a line in test reports. More...

Description

C++ source file with implementations for the µTest++ test reporter methods.

This source file contains the core implementations for the test reporting facilities of the µTest++ framework. It provides the logic for formatting and outputting test results, including operator overloads for a wide range of value types, containers, and comparison expressions, as well as structured output for logical and exception-related assertions.

The test reporter is responsible for presenting test outcomes in a clear, consistent, and expressive manner, supporting both value and pointer semantics, and providing detailed diagnostics for both successful and failed test cases. Special attention is given to formatting, colour highlighting, and extensibility, enabling professional and readable test reports suitable for embedded and general C++ development.

All definitions reside within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

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

Functions

endl()

test_reporter & micro_os_plus::micro_test_plus::endl (test_reporter & stream)

Output stream manipulator for ending a line in test reports.

Parameters
stream

Reference to the test_reporter instance.

Returns

Reference to the same test_reporter instance, enabling chaining of output operations.

The endl function inserts a newline character into the specified test_reporter stream and flushes its output buffer. This operation ensures that each test output line is clearly separated and immediately visible, facilitating the readability and clarity of test results across all test cases and folders within the µTest++ framework.

Definition at line 78 of file test-reporter.cpp.

79 {
80 reporter->endline ();
81 return stream;
82 }

Reference micro_os_plus::micro_test_plus::reporter.

Referenced by micro_os_plus::micro_test_plus::test_reporter_tap::output_fail_prefix_, micro_os_plus::micro_test_plus::test_reporter_basic::output_fail_suffix_, micro_os_plus::micro_test_plus::test_reporter_tap::output_fail_suffix_, micro_os_plus::micro_test_plus::test_reporter_basic::output_pass_suffix_ and micro_os_plus::micro_test_plus::test_reporter_tap::output_pass_suffix_.

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

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.14.0.