micro-test-plus 3.2.2
µTest++ Testing Framework
Loading...
Searching...
No Matches
test-suite.cpp
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
43
44// ----------------------------------------------------------------------------
45
46#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
47#include <micro-os-plus/config.h>
48#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
49
51
52#include <stdio.h>
53
54// ----------------------------------------------------------------------------
55
56#if defined(__clang__)
57#pragma clang diagnostic ignored "-Wc++98-compat"
58#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
59#endif
60
62{
63 // --------------------------------------------------------------------------
64
76 {
77#if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
78 printf ("%s\n", __PRETTY_FUNCTION__);
79#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
80
81 name_ = name;
82 // The default test suite needs no registration.
83 }
84
95
105 void
107 {
108#if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
109 printf ("%s\n", __PRETTY_FUNCTION__);
110#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
111 }
112
121 void
123 {
125
126 reporter.begin_test_suite (name_);
127 }
128
138 void
140 {
142 {
144 }
145 reporter.end_test_suite (*this);
146 }
147
158 void
160 {
162 {
164 }
165
167 ++test_cases_;
168
170
171 reporter.begin_test_case (test_case_name_);
172 }
173
182 void
184 {
185 reporter.end_test_case (test_case_name_);
186 }
187
195 void
197 {
199 ++current_test_case.successful_checks;
200 }
201
209 void
211 {
213 ++current_test_case.failed_checks;
214 }
215
216 // ==========================================================================
217
226 void
228 {
229 // Run the test suite function prepared with std::bin();
230 callable_ ();
231 }
232
242 {
243#if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
244 printf ("%s\n", __PRETTY_FUNCTION__);
245#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
246 }
247
248 // --------------------------------------------------------------------------
249} // namespace micro_os_plus::micro_test_plus
250
251// ----------------------------------------------------------------------------
int failed_checks_
Count of test conditions that failed.
Definition test-suite.h:313
virtual void run(void)
Runs the sequence of test cases in the suite.
test_suite_base(const char *name)
Constructs a test suite.
int test_cases_
Count of test cases in the test suite.
Definition test-suite.h:318
void increment_failed(void)
Increments the count of failed test conditions.
struct micro_os_plus::micro_test_plus::test_suite_base::@307331361010072137141032203112105164200271360345 current_test_case
Structure holding the current test case's check counters.
constexpr const char * name(void)
Gets the suite name.
Definition test-suite.h:178
void begin_test_case(const char *name)
Marks the beginning of a named test case.
const char * name_
The test suite name.
Definition test-suite.h:298
void increment_successful(void)
Increments the count of passed test conditions.
virtual ~test_suite_base()
Virtual destructor for the test_suite_base class.
void end_test_suite(void)
Marks the end of the test suite.
void end_test_case(void)
Marks the end of a test case.
bool process_deferred_begin
Indicates whether to process deferred begin for test cases.
Definition test-suite.h:324
int successful_checks_
Count of test conditions that passed.
Definition test-suite.h:308
void begin_test_suite(void)
Begins the execution of the test suite.
const char * test_case_name_
The current test case name.
Definition test-suite.h:303
std::function< void(void)> callable_
Callable object representing the test suite's execution logic.
Definition test-suite.h:438
virtual void run(void) override
Runs the sequence of test cases in the suite by invoking the stored callable.
virtual ~test_suite() override
Virtual destructor for the test_suite class.
Main C++ header with the declarations for the µTest++ Testing Framework.
Primary namespace for the µTest++ testing framework.
test_reporter reporter
Global instance of test_reporter.