micro-test-plus
5.0.1
µ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_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
"
62
#include "
expression-formatter.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
81
namespace
micro_os_plus::micro_test_plus
82
{
83
class
subtest;
84
85
// --------------------------------------------------------------------------
86
87
namespace
detail
88
{
89
// ========================================================================
90
109
class
deferred_reporter_base
110
{
111
public
:
119
deferred_reporter_base
(
bool
value
,
120
const
reflection::source_location
& location,
121
subtest
&
subtest
);
122
126
deferred_reporter_base
(
const
deferred_reporter_base
&) =
delete
;
127
131
deferred_reporter_base
(
deferred_reporter_base
&&) =
delete
;
132
136
deferred_reporter_base
&
137
operator=
(
const
deferred_reporter_base
&)
138
=
delete
;
139
143
deferred_reporter_base
&
144
operator=
(
deferred_reporter_base
&&)
145
=
delete
;
146
150
~deferred_reporter_base
();
151
160
template
<
class
T>
161
requires
type_traits::printable<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
196
const
reflection::source_location
location_
{};
197
202
std::string
deferred_output_
{};
203
207
subtest
&
subtest_
;
208
};
209
210
// ========================================================================
211
228
class
deferred_reporter
:
public
deferred_reporter_base
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
270
#include "
inlines/deferred-reporter-inlines.h
"
271
272
// ----------------------------------------------------------------------------
273
274
#endif
// MICRO_OS_PLUS_MICRO_TEST_PLUS_DEFERRED_REPORTER_H_
275
276
// ----------------------------------------------------------------------------
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:196
micro_os_plus::micro_test_plus::detail::deferred_reporter_base::value
bool value() const
Retrieves the result value.
Definition
deferred-reporter-inlines.h:88
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:202
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:109
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:191
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:186
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:207
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:180
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:161
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:160
micro_os_plus::micro_test_plus::reflection::source_location
Local implementation of source location information for diagnostics.
Definition
reflection.h:150
micro_os_plus::micro_test_plus::subtest
A named, runnable test case that lives inside a suite.
Definition
test.h:551
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:495
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:88
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
Definition
deferred-reporter.h:82
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