Skip to main content

deferred-reporter.h File

C++ header file with declarations for the µTest++ deferred reporter. More...

Included Headers

#include "type-traits.h" #include "reflection.h" #include "expression-formatter.h" #include <cstdio> #include <string> #include "inlines/deferred-reporter-inlines.h"

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

Classes Index

classdeferred_reporter

Deferred reporter class for a specific expression. More...

classdeferred_reporter_base

Base class for a deferred reporter that collects messages into a string. More...

Description

C++ header file with declarations for the µTest++ deferred reporter.

This header provides the two deferred-reporter classes used by expect() and assume() to capture a test-expression result and format the outcome only when the reporter object is destroyed (i.e. at the semicolon following the expression statement).

  • deferred_reporter_base stores the boolean result, the source location, an optional user-supplied message (accumulated via operator<<), and a reference to the owning subtest. Its destructor calls the reporter to emit a pass or fail line.
  • deferred_reporter<Expr_T> derives from the base and additionally stores the original expression object so that the reporter can print the actual and expected values on failure.

Both classes live in the detail namespace and are not part of the public API.

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
42
43#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
44#define MICRO_OS_PLUS_MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
45
46// ----------------------------------------------------------------------------
47
48#if defined(__cplusplus)
49
50// ----------------------------------------------------------------------------
51
52#if __has_include("micro-os-plus/project-config.h")
53#include "micro-os-plus/project-config.h"
54#endif // __has_include("micro-os-plus/project-config.h")
55
56#if __has_include("micro-os-plus/micro-test-plus-defines.h")
57#include "micro-os-plus/micro-test-plus-defines.h"
58#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
59
60#include "type-traits.h"
61#include "reflection.h"
63
64#include <cstdio>
65#include <string>
66
67// ----------------------------------------------------------------------------
68
69#if defined(__GNUC__)
70#pragma GCC diagnostic push
71
72#pragma GCC diagnostic ignored "-Wpadded"
73#pragma GCC diagnostic ignored "-Waggregate-return"
74#if defined(__clang__)
75#pragma clang diagnostic ignored "-Wc++98-compat"
76#endif // defined(__clang__)
77#endif // defined(__GNUC__)
78
79// ============================================================================
80
82{
83 class subtest;
84
85 // --------------------------------------------------------------------------
86
87 namespace detail
88 {
89 // ========================================================================
90
110 {
111 public:
120 const reflection::source_location& location,
122
127
132
138 = delete;
139
145 = delete;
146
151
160 template <class T>
162 auto&
163 operator<<(const T& msg);
164
173 [[nodiscard]] bool
174 value () const;
175
176 protected:
180 bool value_{};
181
186 bool abort_ = false;
187
191 bool has_expression_ = false;
192
197
202 std::string deferred_output_{};
203
208 };
209
210 // ========================================================================
211
229 {
230 public:
242 template <class Expr_T>
243 deferred_reporter (const Expr_T& expr, bool abort,
244 const reflection::source_location& location,
246
250 ~deferred_reporter () = default;
251 };
252
253 // ------------------------------------------------------------------------
254 } // namespace detail
255
256 // --------------------------------------------------------------------------
257} // namespace micro_os_plus::micro_test_plus
258
259#if defined(__GNUC__)
260#pragma GCC diagnostic pop
261#endif // defined(__GNUC__)
262
263// ----------------------------------------------------------------------------
264
265#endif // defined(__cplusplus)
266
267// ============================================================================
268// Templates, inlines & constexpr implementations.
269
271
272// ----------------------------------------------------------------------------
273
274#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
275
276// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.