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 template implementation for runner::suite(), the method used to create and register a named test suite with a runner instance. The method constructs a suite object on the heap (wrapped in std::unique_ptr), transfers ownership to the runner via register_suite_(), and the newly created suite runs immediately as part of the registration process.

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 intended solely for internal use within the framework and should not be included directly by user code.

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
38
39#ifndef MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
40#define MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
41
42// ----------------------------------------------------------------------------
43
44#ifdef __cplusplus
45
46// ----------------------------------------------------------------------------
47
48#if defined(MICRO_OS_PLUS_TRACE)
49#include <micro-os-plus/diag/trace.h>
50#endif // MICRO_OS_PLUS_TRACE
51
52// ----------------------------------------------------------------------------
53
54#if defined(__GNUC__)
55#pragma GCC diagnostic push
56#pragma GCC diagnostic ignored "-Waggregate-return"
57#if defined(__clang__)
58#pragma clang diagnostic ignored "-Wc++98-compat"
59#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
60#else // GCC only
61#pragma GCC diagnostic ignored "-Wredundant-tags"
62#endif
63#endif
64
65// ============================================================================
66
68{
69 // ==========================================================================
70
75 inline class reporter&
76 runner::reporter (void) const noexcept
77 {
78 return *reporter_;
79 }
80
86 runner::timings () noexcept
87 {
88 return timings_;
89 }
90
95 inline const detail::timestamps&
96 runner::timings () const noexcept
97 {
98 return timings_;
99 }
100
101 // --------------------------------------------------------------------------
102
110 template <typename Callable_T, typename... Args_T>
111 void
112 runner::suite (const char* name, Callable_T&& callable,
113 Args_T&&... arguments)
114 {
115#if defined(MICRO_OS_PLUS_TRACE) \
116 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
117#if defined(__GNUC__)
118#pragma GCC diagnostic push
119#if defined(__clang__)
120#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
121#endif
122#endif
123 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
124#if defined(__GNUC__)
125#pragma GCC diagnostic pop
126#endif
127#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
128
129 auto child_suite = std::make_unique<class suite> (
130 name, *this, std::forward<Callable_T> (callable),
131 std::forward<Args_T> (arguments)...);
132
133 register_suite_ (std::move (child_suite));
134 }
135
136 // --------------------------------------------------------------------------
137} // namespace micro_os_plus::micro_test_plus
138
139#if defined(__GNUC__)
140#pragma GCC diagnostic pop
141#endif
142
143// ----------------------------------------------------------------------------
144
145#endif // __cplusplus
146
147// ----------------------------------------------------------------------------
148
149#endif // MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
150
151// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.