micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
deferred-reporter.h
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
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,
236 subtest& subtest, expression_formatter& expression);
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// ----------------------------------------------------------------------------
const reflection::source_location location_
Stores the source location associated with the report.
std::string deferred_output_
String to collect the expectation message passed via operator<<().
deferred_reporter_base(deferred_reporter_base &&)=delete
Deleted move constructor to prevent moving.
auto & operator<<(const T &msg)
Appends a message to the reporter.
~deferred_reporter_base()
Destructor for the deferred reporter base.
deferred_reporter_base(const deferred_reporter_base &)=delete
Deleted copy constructor to prevent copying.
bool has_expression_
Indicates whether the reporter has an associated expression.
bool abort_
Indicates whether the reporting should abort further processing.
subtest & subtest_
Reference to the test case invoking this report.
deferred_reporter_base(bool value, const reflection::source_location &location, subtest &subtest)
Constructs a deferred reporter base.
deferred_reporter_base & operator=(const deferred_reporter_base &)=delete
Deleted copy assignment operator to prevent copying.
deferred_reporter(const Expr_T &expr, bool abort, const reflection::source_location &location, subtest &subtest, expression_formatter &expression)
Constructs a deferred reporter for a specific expression.
~deferred_reporter()=default
Destructor for the deferred reporter.
Formats values and expressions into an owned string buffer.
Local implementation of source location information for diagnostics.
Definition reflection.h:138
A named, runnable test case that lives inside a suite.
Definition test.h:542
C++20 concept satisfied when a type can be appended to the deferred reporter's output via operator<<.
C++ header file with inline implementations for the µTest++ internals.
C++ header file with declarations for the µTest++ expression formatter.
Internal implementation details for the µTest++ framework.
Primary namespace for the µTest++ testing framework.
C++ header file with declarations for the µTest++ reflection utilities.
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.