Skip to main content

runner-inlines.h File

C++ header file with inline implementations for the µTest++ test runner. More...

Namespaces Index​

namespacemicro_os_plus

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

namespacemicro_test_plus

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

Description​

C++ header file with inline implementations for the µTest++ test runner.

This header provides the inline accessors of the runner class and the inline template implementation for runner::add_suite(), the member function used to create and register a named test suite with a runner instance, and for its deprecated alias runner::suite(). It constructs a suite object on the heap (wrapped in std::unique_ptr) and transfers ownership to the runner via register_suite(); the suite is run later, by run_suites().

The implementation is separated into this inline header so that the template definition is visible at every call site without cluttering the main runner.h declaration file.

This file is included by runner.h; the applications include micro-os-plus/micro-test-plus.h, not this file.

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
35
36#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_RUNNER_INLINES_H_
37#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_RUNNER_INLINES_H_
38
39// ----------------------------------------------------------------------------
40
41#if defined(__cplusplus)
42
43// ----------------------------------------------------------------------------
44
45#if __has_include("micro-os-plus/diag/trace.h")
46#include "micro-os-plus/diag/trace.h"
47#endif // __has_include("micro-os-plus/diag/trace.h")
48
49// ----------------------------------------------------------------------------
50
51#if defined(__GNUC__)
52#pragma GCC diagnostic push
53
54#pragma GCC diagnostic ignored "-Waggregate-return"
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wunknown-warning-option"
57#pragma clang diagnostic ignored "-Wc++98-compat"
58#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
59#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
60#else // GCC only
61#pragma GCC diagnostic ignored "-Wredundant-tags"
62#endif // defined(__clang__)
63#endif // defined(__GNUC__)
64
65// ============================================================================
66
68{
69 // ==========================================================================
70
76 inline auto
78 {
79 return options_.verbosity_level;
80 }
81
86 inline bool
87 runner::is_listing (void) const noexcept
88 {
89 return options_.list_tests;
90 }
91
99 inline bool
100 runner::has_option_errors (void) const noexcept
101 {
102 return options_.has_errors ()
103 || (reporter_ != nullptr && reporter_->has_output_file_error ());
104 }
105
106#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
111 // Deprecated since 6.0.0; use verbosity_level().
112 inline auto
114 {
115 return verbosity_level ();
116 }
117#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
118
123 inline const counters&
124 runner::totals (void) const noexcept
125 {
126 return totals_;
127 }
128
134 inline std::span<const std::string>
135 runner::application_arguments (void) const noexcept
136 {
137 return options_.application_arguments ();
138 }
139
140#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
145 // Deprecated since 6.0.0; the timings are internal.
146 inline const detail::stopwatch&
147 runner::timings (void) const noexcept
148 {
149 return stopwatch_;
150 }
151
156 // Deprecated since 6.0.0; the timings are internal.
157 inline detail::stopwatch&
158 runner::timings (void) noexcept
159 {
160 return stopwatch_;
161 }
162
168 // Deprecated since 6.0.0; use verbosity_level().
169 inline detail::reporter&
170 runner::reporter (void) const noexcept
171 {
172 return *reporter_;
173 }
174#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
175
176 // --------------------------------------------------------------------------
177
188 template <typename Callable_T, typename... Args_T>
189 requires detail::suite_body<Callable_T, Args_T...>
190 void
191 runner::add_suite (located_name name, Callable_T&& callable,
192 Args_T&&... arguments)
193 {
194#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
195 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name.name ());
196#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
197
198 // Not std::make_unique(), which cannot access the private constructor.
199 std::unique_ptr<class suite> child_suite{ new class suite (
200 std::move (name), *this, std::forward<Callable_T> (callable),
201 std::forward<Args_T> (arguments)...) };
202
203 register_suite (std::move (child_suite));
204 }
205
206#if !defined(__DOXYGEN__)
212 template <typename Callable_T, typename... Args_T>
213 requires (!detail::suite_body<Callable_T, Args_T...>)
214 void
215 runner::add_suite ([[maybe_unused]] located_name name,
216 [[maybe_unused]] Callable_T&& callable,
217 [[maybe_unused]] Args_T&&... arguments)
218 {
219 detail::reject_suite_body<Callable_T, Args_T...> ();
220 }
221#endif // !defined(__DOXYGEN__)
222
223#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
228 // Deprecated since 6.0.0; use add_suite().
229 template <typename Callable_T, typename... Args_T>
230 void
231 runner::suite (std::string_view name, Callable_T&& callable,
232 Args_T&&... arguments)
233 {
234 add_suite (located_name{ name }, std::forward<Callable_T> (callable),
235 std::forward<Args_T> (arguments)...);
236 }
237#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
238
239 // --------------------------------------------------------------------------
240} // namespace micro_os_plus::micro_test_plus
241
242#if defined(__GNUC__)
243#pragma GCC diagnostic pop
244#endif // defined(__GNUC__)
245
246// ----------------------------------------------------------------------------
247
248#endif // defined(__cplusplus)
249
250// ----------------------------------------------------------------------------
251
252#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_RUNNER_INLINES_H_
253
254// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.