Skip to main content

counters.h File

C++ header file with declarations for the µTest++ counters. More...

Included Headers​

#include <cstddef> #include "inlines/counters-inlines.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...

Classes Index​

classcounters

Aggregated check and test case counters for a node in the test tree. More...

Description​

C++ header file with declarations for the µTest++ counters.

This header provides the counters class, which aggregates the counts of passed checks, failed checks, and executed test cases for a test runner, test suite, or test case. Instances of this class are embedded inside the runner and every node of the test tree, and updated in place as the test session progresses.

All definitions reside within the micro_os_plus::micro_test_plus namespace.

The class is public, since totals() returns it, and the tests may read their own counters through it.

This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.

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
12// ----------------------------------------------------------------------------
13
34
35#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_COUNTERS_H_
36#define MICRO_OS_PLUS_MICRO_TEST_PLUS_COUNTERS_H_
37
38// ----------------------------------------------------------------------------
39
40#if defined(__cplusplus)
41
42// ----------------------------------------------------------------------------
43
44#if __has_include("micro-os-plus/project-config.h")
45#include "micro-os-plus/project-config.h"
46#endif // __has_include("micro-os-plus/project-config.h")
47
48#if __has_include("micro-os-plus/micro-test-plus-defines.h")
49#include "micro-os-plus/micro-test-plus-defines.h"
50#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
51
52#include <cstddef>
53
54// ----------------------------------------------------------------------------
55
56#if defined(__GNUC__)
57#pragma GCC diagnostic push
58
59#if defined(__clang__)
60#pragma clang diagnostic ignored "-Wc++98-compat"
61#endif // defined(__clang__)
62#endif // defined(__GNUC__)
63
64// ============================================================================
65
67{
68 // ==========================================================================
69
70 class runner;
71 class suite;
72 class test_case;
73
74 namespace detail
75 {
76 class check_result;
77 class runnable_base;
78 } // namespace detail
79
80 // ==========================================================================
81
123 {
124 public:
131 counters (void) = default;
132
144 counters (const counters& other) = default;
145
157 counters (counters&& other) = default;
158
171 operator=(const counters& other)
172 = default;
173
188 = default;
189
196 ~counters () = default;
197
211 [[nodiscard]] size_t
212 passed_checks (void) const noexcept;
213
214#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
219
231 [[deprecated ("use passed_checks() (since 6.0.0)"), nodiscard]] size_t
232 successful_checks (void) const noexcept;
233
237#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
238
246 [[nodiscard]] size_t
247 failed_checks (void) const noexcept;
248
256 [[nodiscard]] size_t
257 executed_checks (void) const noexcept;
258
266 [[nodiscard]] size_t
267 executed_test_cases (void) const noexcept;
268
269#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
274
286 [[deprecated ("use executed_test_cases() (since 6.0.0)"),
287 nodiscard]] size_t
288 executed_subtests (void) const noexcept;
289
293#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
294
302 [[nodiscard]] size_t
303 failed_test_cases (void) const noexcept;
304
317 [[nodiscard]] size_t
318 skipped_test_cases (void) const noexcept;
319
329 [[nodiscard]] bool
330 passed (void) const noexcept;
331
332#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
337
349 [[deprecated ("use passed() (since 6.0.0)"), nodiscard]] bool
350 was_successful (void) const noexcept;
351
355#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
356
357 private:
366 friend class runner;
367
375 friend class suite;
376
384 friend class test_case;
385
393
403
411 operator+=(const counters& other) noexcept;
412
426 void
427 increment_passed_checks (size_t count = 1) noexcept;
428
436 void
437 increment_failed_checks (size_t count = 1) noexcept;
438
446 void
447 increment_executed_test_cases (size_t count = 1) noexcept;
448
456 void
457 increment_failed_test_cases (size_t count = 1) noexcept;
458
468 void
469 increment_skipped_test_cases (size_t count = 1) noexcept;
470
477 size_t passed_checks_ = 0;
478
485 size_t failed_checks_ = 0;
486
495
507
517 };
518
519 // --------------------------------------------------------------------------
520} // namespace micro_os_plus::micro_test_plus
521
522#if defined(__GNUC__)
523#pragma GCC diagnostic pop
524#endif // defined(__GNUC__)
525
526// ----------------------------------------------------------------------------
527
528#endif // defined(__cplusplus)
529
530// ============================================================================
531// Templates, inlines & constexpr implementations.
532
534
535// ----------------------------------------------------------------------------
536
537#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_COUNTERS_H_
538
539// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.