micro-test-plus 5.0.1
µ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_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,
245 subtest& subtest, expression_formatter& expression);
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// ----------------------------------------------------------------------------
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:150
A named, runnable test case that lives inside a suite.
Definition test.h:551
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.