Skip to main content

reporter-inlines.h File

C++ header file with inline implementations for the µTest++ test reporter. More...

Included Headers

#include <cstdio> #include <cstring>

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

detail::indent_tindent (size_t level)

Factory function that creates an indent_t manipulator. More...

Description

C++ header file with inline implementations for the µTest++ test reporter.

This header provides the inline implementations for the test reporting facilities used within the µTest++ framework. It defines the logic for formatting and outputting test results, including operator overloads for various value types, containers, and comparison expressions, as well as structured output for logical and exception-related assertions.

The implementations ensure that test outcomes are presented 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.

The header files are organised within the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.

This file is intended solely for internal use within the framework and should not be included directly by user code.

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
48
49#ifndef MICRO_TEST_PLUS_TEST_REPORTER_INLINES_H_
50#define MICRO_TEST_PLUS_TEST_REPORTER_INLINES_H_
51
52// ----------------------------------------------------------------------------
53
54#ifdef __cplusplus
55
56// ----------------------------------------------------------------------------
57
58#include <cstdio>
59#include <cstring>
60
61// ----------------------------------------------------------------------------
62
63#if defined(__GNUC__)
64#pragma GCC diagnostic push
65#pragma GCC diagnostic ignored "-Waggregate-return"
66#if defined(__clang__)
67#pragma clang diagnostic ignored "-Wc++98-compat"
68#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
69#endif
70#endif
71
72// ============================================================================
73
75{
76 // --------------------------------------------------------------------------
77
79 indent (size_t level)
80 {
81 return { level };
82 }
83
84 // ==========================================================================
85
90 inline auto
92 {
93 return verbosity_;
94 }
95
107 {
108 return expression_;
109 }
110
116 inline auto
117 reporter::colour_ (const bool cond) const
118 {
119 return cond ? colours_.pass : colours_.fail;
120 }
121
122 // --------------------------------------------------------------------------
123
142 template <typename T>
145 {
146 if (v == nullptr)
147 {
148 // Explicitly render null pointers as "0x0" to avoid platform-specific
149 // representations such as "(nil)" on Linux/glibc.
150 buffer_.append ("0x0");
151 return *this;
152 }
153#if defined(__GNUC__)
154#pragma GCC diagnostic push
155#if defined(__clang__)
156#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
157#endif
158#endif
159 char buff[20];
160 snprintf (buff, sizeof (buff), "%p", reinterpret_cast<void*> (v));
161 buffer_.append (buff);
162#if defined(__GNUC__)
163#pragma GCC diagnostic pop
164#endif
165
166 return *this;
167 }
168
181 template <class T>
182 requires std::is_arithmetic_v<T>
185 {
187 return *this;
188 }
189
190 // --------------------------------------------------------------------------
191} // namespace micro_os_plus::micro_test_plus
192
193#if defined(__GNUC__)
194#pragma GCC diagnostic pop
195#endif
196
197// ----------------------------------------------------------------------------
198
199#endif // __cplusplus
200
201// ----------------------------------------------------------------------------
202
203#endif // MICRO_TEST_PLUS_TEST_REPORTER_INLINES_H_
204
205// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.