Skip to main content

deferred-reporter.h File

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

Included Headers

#include <cstdio> #include <string> #include "type-traits.h" #include "reflection.h" #include "expression-formatter.h" #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_TEST_PLUS_DEFERRED_REPORTER_H_
44#define MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
45
46// ----------------------------------------------------------------------------
47
48#ifdef __cplusplus
49
50// ----------------------------------------------------------------------------
51
52#include <cstdio>
53#include <string>
54
55#include "type-traits.h"
56#include "reflection.h"
58
59// ----------------------------------------------------------------------------
60
61#if defined(__GNUC__)
62#pragma GCC diagnostic push
63#pragma GCC diagnostic ignored "-Wpadded"
64#pragma GCC diagnostic ignored "-Waggregate-return"
65#if defined(__clang__)
66#pragma clang diagnostic ignored "-Wc++98-compat"
67#endif
68#endif
69
70// ============================================================================
71
73{
74 class subtest;
75
76 // --------------------------------------------------------------------------
77
78 namespace detail
79 {
80 // ========================================================================
81
101 {
102 public:
111 const reflection::source_location& location,
113
118
123
129 = delete;
130
136 = delete;
137
142
151 template <class T>
153 auto&
154 operator<<(const T& msg);
155
164 [[nodiscard]] bool
165 value () const;
166
167 protected:
171 bool value_{};
172
177 bool abort_ = false;
178
182 bool has_expression_ = false;
183
188
193 std::string deferred_output_{};
194
199 };
200
201 // ========================================================================
202
220 {
221 public:
233 template <class Expr_T>
234 deferred_reporter (const Expr_T& expr, bool abort,
235 const reflection::source_location& location,
237
241 ~deferred_reporter () = default;
242 };
243
244 // ------------------------------------------------------------------------
245 } // namespace detail
246
247 // --------------------------------------------------------------------------
248} // namespace micro_os_plus::micro_test_plus
249
250#if defined(__GNUC__)
251#pragma GCC diagnostic pop
252#endif
253
254// ----------------------------------------------------------------------------
255
256#endif // __cplusplus
257
258// ============================================================================
259// Templates & constexpr implementations.
260
262
263// ----------------------------------------------------------------------------
264
265#endif // MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
266
267// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.