micro-test-plus 3.2.0
µTest++, a lightweight testing framework for embedded platforms
Loading...
Searching...
No Matches
test-suite.cpp
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// ----------------------------------------------------------------------------
18
19#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
20#include <micro-os-plus/config.h>
21#endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
22
24
25#include <stdio.h>
26
27// ----------------------------------------------------------------------------
28
29#if defined(__clang__)
30#pragma clang diagnostic ignored "-Wc++98-compat"
31#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
32#endif
33
35{
36 // --------------------------------------------------------------------------
37
39 {
40#if defined(MICRO_TEST_PLUS_TRACE)
41 printf ("%s\n", __PRETTY_FUNCTION__);
42#endif // MICRO_TEST_PLUS_TRACE
43
44 name_ = name;
45 // The default test suite needs no registration.
46 }
47
51
52 void
54 {
55#if defined(MICRO_TEST_PLUS_TRACE)
56 printf ("%s\n", __PRETTY_FUNCTION__);
57#endif // MICRO_TEST_PLUS_TRACE
58 }
59
60 void
67
68 void
77
78 void
93
94 void
99
100 void
102 {
104 ++current_test_case.successful_checks;
105 }
106
107 void
109 {
111 ++current_test_case.failed_checks;
112 }
113
114 // ==========================================================================
115
116 void
118 {
119 // Run the test suite function prepared with std::bin();
120 callable_ ();
121 }
122
124 {
125#if defined(MICRO_TEST_PLUS_TRACE)
126 printf ("%s\n", __PRETTY_FUNCTION__);
127#endif // MICRO_TEST_PLUS_TRACE
128 }
129
130 // --------------------------------------------------------------------------
131} // namespace micro_os_plus::micro_test_plus
132
133// ----------------------------------------------------------------------------
int failed_checks_
Count of test conditions that failed.
Definition test-suite.h:233
virtual void run(void)
Run the sequence of test cases in the suite.
test_suite_base(const char *name)
Construct a test suite.
int test_cases_
Count of test cases in the test suite.
Definition test-suite.h:238
void increment_failed(void)
Count one more failed test conditions.
void begin_test_case(const char *name)
Mark the beginning of a named test case.
const char * name_
The test suite name.
Definition test-suite.h:218
void increment_successful(void)
Count one more passed test conditions.
constexpr const char * name()
Get the suite name.
Definition test-suite.h:107
void end_test_suite(void)
Mark the end of the test suite.
void end_test_case(void)
Mark the end of a test case.
int successful_checks_
Count of test conditions that passed.
Definition test-suite.h:228
void begin_test_suite(void)
Begin the execution of the test suite.
const char * test_case_name_
The current test case name.
Definition test-suite.h:223
struct micro_os_plus::micro_test_plus::test_suite_base::@0 current_test_case
std::function< void(void)> callable_
Definition test-suite.h:289
virtual void run(void) override
Run the sequence of test cases in the suite.