micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
runner-totals.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
36
37#ifndef MICRO_TEST_PLUS_TEST_RUNNER_TOTALS_H_
38#define MICRO_TEST_PLUS_TEST_RUNNER_TOTALS_H_
39
40// ----------------------------------------------------------------------------
41
42#ifdef __cplusplus
43
44// ----------------------------------------------------------------------------
45
46#include <cstddef>
47
48// ----------------------------------------------------------------------------
49
50#if defined(__GNUC__)
51#pragma GCC diagnostic push
52#if defined(__clang__)
53#pragma clang diagnostic ignored "-Wc++98-compat"
54#endif
55#endif
56
57// ============================================================================
58
60{
61 // --------------------------------------------------------------------------
62
63 namespace detail
64 {
65 // ========================================================================
66
89 {
90 public:
94 runner_totals () = default;
95
99 runner_totals (const runner_totals&) = delete;
100
105
111 = delete;
112
118 = delete;
119
127 operator+= (const runner_totals& other) noexcept;
128
136 void
137 increment_successful_checks (size_t count = 1) noexcept;
138
146 void
147 increment_failed_checks (size_t count = 1) noexcept;
148
156 void
157 increment_executed_subtests (size_t count = 1) noexcept;
158
166 [[nodiscard]] size_t
167 successful_checks () const noexcept;
168
176 [[nodiscard]] size_t
177 failed_checks () const noexcept;
178
186 [[nodiscard]] size_t
187 executed_checks () const noexcept;
188
196 [[nodiscard]] size_t
197 executed_subtests () const noexcept;
198
207 [[nodiscard]] bool
208 was_successful (void) const noexcept;
209
210 protected:
215
219 size_t failed_checks_ = 0;
220
225 };
226
227 // ------------------------------------------------------------------------
228 } // namespace detail
229
230 // --------------------------------------------------------------------------
231} // namespace micro_os_plus::micro_test_plus
232
233#if defined(__GNUC__)
234#pragma GCC diagnostic pop
235#endif
236
237// ----------------------------------------------------------------------------
238
239#endif // __cplusplus
240
241// ============================================================================
242// Templates & constexpr implementations.
243
245
246// ----------------------------------------------------------------------------
247
248#endif // MICRO_TEST_PLUS_TEST_RUNNER_TOTALS_H_
249
250// ----------------------------------------------------------------------------
void increment_successful_checks(size_t count=1) noexcept
Increments the successful-checks counter.
size_t successful_checks_
Total number of successful checks.
size_t executed_subtests() const noexcept
Returns the number of subtests that were executed.
runner_totals & operator+=(const runner_totals &other) noexcept
Accumulates the totals from another instance into this one.
runner_totals(const runner_totals &)=delete
Deleted copy constructor to prevent copying.
runner_totals(runner_totals &&)=delete
Deleted move constructor to prevent moving.
size_t successful_checks() const noexcept
Returns the number of checks that passed.
bool was_successful(void) const noexcept
Checks whether all executed checks were successful.
void increment_executed_subtests(size_t count=1) noexcept
Increments the executed-subtests counter.
size_t failed_checks_
Total number of failed checks.
size_t executed_subtests_
Total number of tests executed.
void increment_failed_checks(size_t count=1) noexcept
Increments the failed-checks counter.
size_t failed_checks() const noexcept
Returns the number of checks that failed.
runner_totals()=default
Default constructor. All counters are zero-initialised.
runner_totals & operator=(const runner_totals &)=delete
Deleted copy assignment operator to prevent copying.
size_t executed_checks() const noexcept
Returns the total number of checks executed.
Internal implementation details for the µTest++ framework.
Primary namespace for the µTest++ testing framework.
C++ header file with inline implementations for the µTest++ runner totals.