micro-test-plus
4.1.0
µTest++ Testing Framework
Toggle main menu visibility
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
"
57
#include "
expression-formatter.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
72
namespace
micro_os_plus::micro_test_plus
73
{
74
class
subtest
;
75
76
// --------------------------------------------------------------------------
77
78
namespace
detail
79
{
80
// ========================================================================
81
100
class
deferred_reporter_base
101
{
102
public
:
110
deferred_reporter_base
(
bool
value
,
111
const
reflection::source_location
& location,
112
subtest
&
subtest
);
113
117
deferred_reporter_base
(
const
deferred_reporter_base
&) =
delete
;
118
122
deferred_reporter_base
(
deferred_reporter_base
&&) =
delete
;
123
127
deferred_reporter_base
&
128
operator=
(
const
deferred_reporter_base
&)
129
=
delete
;
130
134
deferred_reporter_base
&
135
operator=
(
deferred_reporter_base
&&)
136
=
delete
;
137
141
~deferred_reporter_base
();
142
151
template
<
class
T>
152
requires
type_traits::printable<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
187
const
reflection::source_location
location_
{};
188
193
std::string
deferred_output_
{};
194
198
subtest
&
subtest_
;
199
};
200
201
// ========================================================================
202
219
class
deferred_reporter
:
public
deferred_reporter_base
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
261
#include "
inlines/deferred-reporter-inlines.h
"
262
263
// ----------------------------------------------------------------------------
264
265
#endif
// MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
266
267
// ----------------------------------------------------------------------------
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::location_
const reflection::source_location location_
Stores the source location associated with the report.
Definition
deferred-reporter.h:187
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::value
bool value() const
Retrieves the result value.
Definition
deferred-reporter-inlines.h:87
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::deferred_output_
std::string deferred_output_
String to collect the expectation message passed via operator<<().
Definition
deferred-reporter.h:193
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::deferred_reporter_base
deferred_reporter_base(deferred_reporter_base &&)=delete
Deleted move constructor to prevent moving.
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::operator<<
auto & operator<<(const T &msg)
Appends a message to the reporter.
Definition
deferred-reporter-inlines.h:108
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::~deferred_reporter_base
~deferred_reporter_base()
Destructor for the deferred reporter base.
Definition
deferred-reporter.cpp:103
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::deferred_reporter_base
deferred_reporter_base(const deferred_reporter_base &)=delete
Deleted copy constructor to prevent copying.
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::has_expression_
bool has_expression_
Indicates whether the reporter has an associated expression.
Definition
deferred-reporter.h:182
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::abort_
bool abort_
Indicates whether the reporting should abort further processing.
Definition
deferred-reporter.h:177
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::subtest_
subtest & subtest_
Reference to the test case invoking this report.
Definition
deferred-reporter.h:198
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::deferred_reporter_base
deferred_reporter_base(bool value, const reflection::source_location &location, subtest &subtest)
Constructs a deferred reporter base.
Definition
deferred-reporter.cpp:75
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::operator=
deferred_reporter_base & operator=(const deferred_reporter_base &)=delete
Deleted copy assignment operator to prevent copying.
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::value_
bool value_
Stores the result value of the report.
Definition
deferred-reporter.h:171
micro_os_plus::micro_test_plus::detail::deferred_reporter::deferred_reporter
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.
Definition
deferred-reporter-inlines.h:157
micro_os_plus::micro_test_plus::detail::deferred_reporter::~deferred_reporter
~deferred_reporter()=default
Destructor for the deferred reporter.
micro_os_plus::micro_test_plus::detail::expression_formatter
Formats values and expressions into an owned string buffer.
Definition
expression-formatter.h:151
micro_os_plus::micro_test_plus::reflection::source_location
Local implementation of source location information for diagnostics.
Definition
reflection.h:138
micro_os_plus::micro_test_plus::subtest
A named, runnable test case that lives inside a suite.
Definition
test.h:542
micro_os_plus::micro_test_plus::type_traits::printable
C++20 concept satisfied when a type can be appended to the deferred reporter's output via operator<<.
Definition
type-traits.h:486
deferred-reporter-inlines.h
C++ header file with inline implementations for the µTest++ internals.
expression-formatter.h
C++ header file with declarations for the µTest++ expression formatter.
micro_os_plus::micro_test_plus::detail
Internal implementation details for the µTest++ framework.
Definition
deferred-reporter.h:79
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
reflection.h
C++ header file with declarations for the µTest++ reflection utilities.
type-traits.h
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.
include
micro-os-plus
micro-test-plus
deferred-reporter.h
Generated by
1.17.0