micro-test-plus 3.2.0
µTest++, a lightweight testing framework for embedded platforms
Loading...
Searching...
No Matches
test-runner.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ distribution.
3 * (https://github.com/micro-os-plus/)
4 * Copyright (c) 2021 Liviu Ionescu.
5 *
6 * Permission to use, copy, modify, and/or distribute this software
7 * for any purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can
10 * be obtained from <https://opensource.org/licenses/MIT/>.
11 *
12 * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
13 * released under the terms of the Boost Version 1.0 Software License,
14 * which can be obtained from <https://www.boost.org/LICENSE_1_0.txt>.
15 */
16
17#ifndef MICRO_TEST_PLUS_TEST_RUNNER_H_
18#define MICRO_TEST_PLUS_TEST_RUNNER_H_
19
20// ----------------------------------------------------------------------------
21
22#ifdef __cplusplus
23
24// ----------------------------------------------------------------------------
25
26#include <functional>
27
28// ----------------------------------------------------------------------------
29
30#if defined(__GNUC__)
31#pragma GCC diagnostic push
32#pragma GCC diagnostic ignored "-Wpadded"
33#if defined(__clang__)
34#pragma clang diagnostic ignored "-Wc++98-compat"
35#endif
36#endif
37
39{
40 // --------------------------------------------------------------------------
41
42 class test_suite_base;
43
44 // --------------------------------------------------------------------------
45
52 {
53 public:
54 test_runner ();
55
56 // The rule of five.
57 test_runner (const test_runner&) = delete;
61 = delete;
64 = delete;
65
66 ~test_runner () = default;
67
72 void
73 initialize (int argc, char* argv[], const char* name);
74
78 int
79 exit_code (void);
80
85 void
87
88 constexpr const char*
89 name (void)
90 {
92 }
93
94 [[noreturn]] void
95 abort (void);
96
97 protected:
98 int argc_ = 0;
99 char** argv_ = nullptr;
100
101 const char* default_suite_name_ = "Test";
102
108
115 std::vector<test_suite_base*>* suites_;
116 };
117
118 // --------------------------------------------------------------------------
119} // namespace micro_os_plus::micro_test_plus
120
121#if defined(__GNUC__)
122#pragma GCC diagnostic pop
123#endif
124
125// ----------------------------------------------------------------------------
126
127#endif // __cplusplus
128
129// ----------------------------------------------------------------------------
130
131#endif // MICRO_TEST_PLUS_TEST_RUNNER_H_
132
133// ----------------------------------------------------------------------------
The test runner. It maintains a list of test suites which automatically register themselves in their ...
Definition test-runner.h:52
test_runner & operator=(const test_runner &)=delete
std::vector< test_suite_base * > * suites_
Pointer to array of registered test suites. Statically initialised to zero as BSS,...
constexpr const char * name(void)
Definition test-runner.h:89
test_suite_base * default_test_suite_
Pointer to the default test suite which groups the main tests.
test_runner(const test_runner &)=delete
int exit_code(void)
Return 0 if the all tests were successful, 1 otherwise.
void initialize(int argc, char *argv[], const char *name)
Pass the main arguments explicitly, if the default constructor was used.
void register_test_suite(test_suite_base *suite)
Called by test suite constructors to register them to the runner.
Base class for all test suites.
Definition test-suite.h:51