micro-test-plus
5.0.1
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
deferred-reporter.cpp
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
36
37
// ----------------------------------------------------------------------------
38
39
#include "
micro-os-plus/micro-test-plus/deferred-reporter.h
"
40
#include "
micro-os-plus/micro-test-plus/test.h
"
41
42
#if __has_include("micro-os-plus/diag/trace.h")
43
#include "micro-os-plus/diag/trace.h"
44
#endif
// __has_include("micro-os-plus/diag/trace.h")
45
46
// ----------------------------------------------------------------------------
47
48
#if defined(__GNUC__)
49
#pragma GCC diagnostic ignored "-Waggregate-return"
50
#if defined(__clang__)
51
#pragma clang diagnostic ignored "-Wc++98-compat"
52
#pragma clang diagnostic ignored "-Wexit-time-destructors"
53
#pragma clang diagnostic ignored "-Wglobal-constructors"
54
#endif
// defined(__clang__)
55
#endif
// defined(__GNUC__)
56
57
// ============================================================================
58
59
#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
60
61
// ----------------------------------------------------------------------------
62
63
namespace
micro_os_plus::micro_test_plus
64
{
65
// --------------------------------------------------------------------------
66
namespace
detail
67
{
75
deferred_reporter_base::deferred_reporter_base
(
76
bool
value
,
const
reflection::source_location
& location,
77
subtest
&
subtest
)
78
:
value_
{
value
},
location_
{ location },
subtest_
{
subtest
}
79
{
80
// The index starts at 0, must be incremented before the first check is
81
// reported, to ensure that the first check is reported as check #1.
82
subtest_
.increment_subtest_index ();
83
}
84
103
deferred_reporter_base::~deferred_reporter_base
()
104
{
105
#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
106
trace::printf (
"%s\n"
, __PRETTY_FUNCTION__);
107
#endif
// MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
108
109
auto
& expression_str =
subtest_
.reporter ().expression ().str ();
110
111
if
(
value_
) [[likely]]
112
{
113
subtest_
.reporter ().pass (
deferred_output_
, expression_str,
114
subtest_
);
115
subtest_
.totals ().increment_successful_checks ();
116
}
117
else
118
{
119
subtest_
.reporter ().fail (
abort_
,
deferred_output_
, expression_str,
120
has_expression_
,
location_
,
subtest_
);
121
subtest_
.totals ().increment_failed_checks ();
122
}
123
124
if
(
abort_
&& !
value_
) [[unlikely]]
125
{
126
subtest_
.reporter ().write_buffer_to_stdout ();
127
subtest_
.reporter ().flush ();
128
subtest_
.abort (
location_
);
129
}
130
}
131
}
// namespace detail
132
133
// --------------------------------------------------------------------------
134
}
// namespace micro_os_plus::micro_test_plus
135
136
// ----------------------------------------------------------------------------
137
138
#endif
// defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
139
140
// ----------------------------------------------------------------------------
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()
Destructor for the deferred reporter base.
Definition
deferred-reporter.cpp:103
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::value_
bool value_
Stores the result value of the report.
Definition
deferred-reporter.h:180
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
deferred-reporter.h
C++ header file with declarations for the µTest++ deferred reporter.
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
test.h
C++ header file with declarations for the µTest++ test suite.
src
deferred-reporter.cpp
Generated by
1.17.0