micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
test-runner.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 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any 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
9 * be 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
44
45#ifndef MICRO_TEST_PLUS_TEST_RUNNER_H_
46#define MICRO_TEST_PLUS_TEST_RUNNER_H_
47
48// ----------------------------------------------------------------------------
49
50#ifdef __cplusplus
51
52// ----------------------------------------------------------------------------
53
54#include <functional>
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic push
60#pragma GCC diagnostic ignored "-Wpadded"
61#if defined(__clang__)
62#pragma clang diagnostic ignored "-Wc++98-compat"
63#endif
64#endif
65
67{
68 // --------------------------------------------------------------------------
69
70 // Forward definition.
71 class test_suite_base;
72
73 // --------------------------------------------------------------------------
74
97 {
98 public:
105 test_runner ();
106
110 test_runner (const test_runner&) = delete;
111
116
122 = delete;
123
129 = delete;
130
134 ~test_runner () = default;
135
146 void
147 initialize (int argc, char* argv[], const char* name);
148
156 int
157 exit_code (void);
158
166 void
168
177 constexpr const char*
178 name (void)
179 {
180 return default_suite_name_;
181 }
182
191 [[noreturn]] void
192 abort (void);
193
194 protected:
198 int argc_ = 0;
199
203 char** argv_ = nullptr;
204
208 const char* default_suite_name_ = "Test";
209
214
223 std::vector<test_suite_base*>* suites_;
224 };
225
226 // --------------------------------------------------------------------------
227} // namespace micro_os_plus::micro_test_plus
228
229#if defined(__GNUC__)
230#pragma GCC diagnostic pop
231#endif
232
233// ----------------------------------------------------------------------------
234
235#endif // __cplusplus
236
237// ----------------------------------------------------------------------------
238
239#endif // MICRO_TEST_PLUS_TEST_RUNNER_H_
240
241// ----------------------------------------------------------------------------
char ** argv_
Stores the argument vector passed to the test runner.
void abort(void)
Aborts test execution immediately.
test_runner & operator=(const test_runner &)=delete
Deleted copy assignment operator to prevent copying.
std::vector< test_suite_base * > * suites_
Pointer to the array of registered test suites.
test_runner(test_runner &&)=delete
Deleted move constructor to prevent moving.
test_runner()
Default constructor for the test_runner class.
constexpr const char * name(void)
Retrieves the name of the default test suite.
int argc_
Stores the argument count passed to the test runner.
~test_runner()=default
Destructor for the test_runner class.
test_suite_base * default_test_suite_
Pointer to the default test suite which groups the main tests.
test_runner(const test_runner &)=delete
Deleted copy constructor to prevent copying.
int exit_code(void)
Returns 0 if all tests were successful, 1 otherwise.
void initialize(int argc, char *argv[], const char *name)
Initialises the test runner with command-line arguments and an optional suite name.
void register_test_suite(test_suite_base *suite)
Registers a test suite with the runner.
const char * default_suite_name_
The name of the default test suite.
Base class for all test suites.
Definition test-suite.h:98
Primary namespace for the µTest++ testing framework.