micro-test-plus
4.1.1
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
runner-inlines.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
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 "-Wunknown-warning-option"
59
#pragma clang diagnostic ignored "-Wc++98-compat"
60
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
61
#else
// GCC only
62
#pragma GCC diagnostic ignored "-Wredundant-tags"
63
#endif
64
#endif
65
66
// ============================================================================
67
68
namespace
micro_os_plus::micro_test_plus
69
{
70
// ==========================================================================
71
76
inline
class
reporter
&
77
runner::reporter
(
void
)
const
noexcept
78
{
79
return
*
reporter_
;
80
}
81
86
inline
detail::timestamps
&
87
runner::timings
() noexcept
88
{
89
return
timings_
;
90
}
91
96
inline
const
detail::timestamps
&
97
runner::timings
() const noexcept
98
{
99
return
timings_
;
100
}
101
102
// --------------------------------------------------------------------------
103
111
template
<
typename
Callable_T,
typename
... Args_T>
112
void
113
runner::suite
(
const
char
*
name
, Callable_T&& callable,
114
Args_T&&... arguments)
115
{
116
#if defined(MICRO_OS_PLUS_TRACE) \
117
&& defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
118
#if defined(__GNUC__)
119
#pragma GCC diagnostic push
120
#if defined(__clang__)
121
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
122
#endif
123
#endif
124
trace::printf (
"%s '%s'\n"
, __PRETTY_FUNCTION__,
name
);
125
#if defined(__GNUC__)
126
#pragma GCC diagnostic pop
127
#endif
128
#endif
// MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
129
130
auto
child_suite = std::make_unique<class suite> (
131
name
, *
this
, std::forward<Callable_T> (callable),
132
std::forward<Args_T> (arguments)...);
133
134
register_suite_
(std::move (child_suite));
135
}
136
137
// --------------------------------------------------------------------------
138
}
// namespace micro_os_plus::micro_test_plus
139
140
#if defined(__GNUC__)
141
#pragma GCC diagnostic pop
142
#endif
143
144
// ----------------------------------------------------------------------------
145
146
#endif
// __cplusplus
147
148
// ----------------------------------------------------------------------------
149
150
#endif
// MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
151
152
// ----------------------------------------------------------------------------
micro_os_plus::micro_test_plus::detail::test_node::name
const char * name(void) const noexcept
Gets the node name.
Definition
test-inlines.h:92
micro_os_plus::micro_test_plus::detail::timestamps
A begin/end timestamp pair used to measure elapsed time.
Definition
timings.h:205
micro_os_plus::micro_test_plus::reporter
Reporter to display test results, including operand values and types for failures.
Definition
reporter.h:186
micro_os_plus::micro_test_plus::runner::timings
detail::timestamps & timings() noexcept
Gets the timings for this runner.
Definition
runner-inlines.h:87
micro_os_plus::micro_test_plus::runner::reporter
class reporter & reporter(void) const noexcept
Returns a reference to the test reporter.
Definition
runner-inlines.h:77
micro_os_plus::micro_test_plus::runner::suite
void suite(const char *name, Callable_T &&callable, Args_T &&... arguments)
Adds a test suite to the runner.
Definition
runner-inlines.h:113
micro_os_plus::micro_test_plus::runner::timings_
detail::timestamps timings_
Timings for this runner.
Definition
runner.h:311
micro_os_plus::micro_test_plus::runner::register_suite_
void register_suite_(std::unique_ptr< class suite > suite)
Registers a test suite with the runner.
Definition
runner.cpp:316
micro_os_plus::micro_test_plus::runner::reporter_
std::unique_ptr< class reporter > reporter_
Pointer to the test reporter used for outputting test results.
Definition
runner.h:306
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
include
micro-os-plus
micro-test-plus
inlines
runner-inlines.h
Generated by
1.17.0