Skip to main content

deferred-reporter.cpp File

C++ source file with implementations for the µTest++ deferred reporter methods. More...

Included Headers

#include <micro-os-plus/diag/trace.h> #include "micro-os-plus/micro-test-plus/deferred-reporter.h" #include "micro-os-plus/micro-test-plus/test.h"

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

namespacedetail

Internal implementation details for the µTest++ framework. More...

Description

C++ source file with implementations for the µTest++ deferred reporter methods.

This source file contains the implementation of the detail::deferred_reporter_base class, which supports deferred reporting of test expression results. The constructor captures the result value, source location, and subtest reference; the destructor updates the subtest counters and optionally aborts execution on critical failures.

All definitions reside within the micro_os_plus::micro_test_plus::detail namespace.

This file must be included when building the µTest++ library.

File Listing

The file content with the documentation metadata removed is:

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 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
36
37// ----------------------------------------------------------------------------
38
39#if __has_include(<micro-os-plus/project-config.h>)
40#include <micro-os-plus/project-config.h>
41#elif __has_include(<micro-os-plus/config.h>)
42#pragma message \
43 "micro-os-plus/config.h is deprecated, rename to micro-os-plus/project-config.h and include it instead of micro-os-plus/config.h"
44#include <micro-os-plus/config.h>
45#endif // __has_include(<micro-os-plus/project-config.h>)
46
47#if __has_include(<micro-os-plus/micro-test-plus-defines.h>)
48#include <micro-os-plus/micro-test-plus-defines.h>
49#endif // __has_include(<micro-os-plus/micro-test-plus-defines.h>)
50
51#include <micro-os-plus/diag/trace.h>
52
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic ignored "-Waggregate-return"
60#if defined(__clang__)
61#pragma clang diagnostic ignored "-Wc++98-compat"
62#pragma clang diagnostic ignored "-Wexit-time-destructors"
63#pragma clang diagnostic ignored "-Wglobal-constructors"
64#endif
65#endif
66
67// ============================================================================
68
70{
71 // --------------------------------------------------------------------------
72 namespace detail
73 {
82 bool value, const reflection::source_location& location,
84 : value_{ value }, location_{ location }, subtest_{ subtest }
85 {
86 // The index starts at 0, must be incremented before the first check is
87 // reported, to ensure that the first check is reported as check #1.
88 subtest_.increment_subtest_index ();
89 }
90
110 {
111#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
112 trace::printf ("%s\n", __PRETTY_FUNCTION__);
113#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
114
115 auto& expression_str = subtest_.reporter ().expression ().str ();
116
117 if (value_) [[likely]]
118 {
119 subtest_.reporter ().pass (deferred_output_, expression_str,
120 subtest_);
121 subtest_.totals ().increment_successful_checks ();
122 }
123 else
124 {
125 subtest_.reporter ().fail (abort_, deferred_output_, expression_str,
127 subtest_.totals ().increment_failed_checks ();
128 }
129
130 if (abort_ && !value_) [[unlikely]]
131 {
132 subtest_.reporter ().write_buffer_to_stdout ();
133 subtest_.reporter ().flush ();
134 subtest_.abort (location_);
135 }
136 }
137 } // namespace detail
138
139 // ==========================================================================
140} // namespace micro_os_plus::micro_test_plus
141
142// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.17.0.