Skip to main content

The test-suite.cpp File Reference

C++ source file with implementations for the µTest++ test suite methods. More...

Included Headers

#include <micro-os-plus/micro-test-plus.h>
#include <stdio.h>

Namespaces Index

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_os_plus::micro_test_plus

Primary namespace for the µTest++ testing framework. More...

Description

C++ source file with implementations for the µTest++ test suite methods.

This source file contains the core implementations for the test suite facilities of the µTest++ framework. It provides the logic for constructing, registering, and managing test suites and their associated test cases. The implementation covers initialisation and clean-up routines, execution of test suites and test cases, tracking of successful and failed checks, and integration with the test reporter for structured output.

The design ensures that test suites are non-copyable and non-movable, maintaining unique ownership and consistent state. Flexible support for callable objects enables a wide range of test suite definitions, facilitating expressive and maintainable test organisation across embedded and general C++ projects.

All definitions reside within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

This file must be included when building the µTest++ library.

File Listing

The file content with the documentation metadata removed is:

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
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 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE&#95;1&#95;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
93 {
94 }
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
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// ----------------------------------------------------------------------------

Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.