Skip to main content

check-result.h File

C++ header file with declarations for the µTest++ check result. More...

Included Headers​

#include "expression-formatter.h" #include "extension.h" #include "reflection.h" #include <cstdio> #include <string> #include "inlines/check-result-inlines.h"

Namespaces Index​

namespacemicro_os_plus

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

namespacemicro_test_plus

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

namespacedetail

Internal implementation details for the µTest++ framework. More...

Classes Index​

classcheck_result

The result of one check, reported when destroyed. More...

structfailure_info

The details of a check, displayed when it fails. More...

Enumerations Index​

enum classcheck_kind { ... }

The kind of a check, which determines what happens when it fails. More...

Description​

C++ header file with declarations for the µTest++ check result.

This header provides the check_result class, the object returned by expect() and require(), together with the check_kind enumeration and the failure_info structure, passed to the reporter. The check result captures the result of one check and reports the outcome only when it is destroyed (i.e. at the semicolon following the expression statement), after the optional user message was appended via operator<<.

It also defines failed_requirement, the exception thrown to stop a test case after a failed require().

All live in the detail namespace and are not part of the public API.

This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.

Enumerations​

check_kind​

enum class micro_os_plus::micro_test_plus::detail::check_kind
strong

The kind of a check, which determines what happens when it fails.

Enumeration values
expectation A check created by expect()

A failure is reported and counted, and the test case continues.

requirement A check created by require()

A failure is reported and counted, and the test case is stopped, or, without exceptions, the test execution is aborted.

An enumeration rather than a Boolean flag, so that the call sites name the kind of the check.

Definition at line 93 of file check-result.h.

94 {
102
111 };

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-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * 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 be
9 * obtained from https://opensource.org/licenses/mit.
10 */
11
12// ----------------------------------------------------------------------------
13
36
37#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_CHECK_RESULT_H_
38#define MICRO_OS_PLUS_MICRO_TEST_PLUS_CHECK_RESULT_H_
39
40// ----------------------------------------------------------------------------
41
42#if defined(__cplusplus)
43
44// ----------------------------------------------------------------------------
45
46#if __has_include("micro-os-plus/project-config.h")
47#include "micro-os-plus/project-config.h"
48#endif // __has_include("micro-os-plus/project-config.h")
49
50#if __has_include("micro-os-plus/micro-test-plus-defines.h")
51#include "micro-os-plus/micro-test-plus-defines.h"
52#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
53
55#include "extension.h"
56#include "reflection.h"
57
58#include <cstdio>
59#include <string>
60
61// ----------------------------------------------------------------------------
62
63#if defined(__GNUC__)
64#pragma GCC diagnostic push
65
66#pragma GCC diagnostic ignored "-Wpadded"
67#pragma GCC diagnostic ignored "-Waggregate-return"
68#if defined(__clang__)
69#pragma clang diagnostic ignored "-Wc++98-compat"
70#endif // defined(__clang__)
71#endif // defined(__GNUC__)
72
73// ============================================================================
74
76{
77 class test_case;
78
79 // --------------------------------------------------------------------------
80
81 namespace detail
82 {
83 // ========================================================================
84
93 enum class check_kind
94 {
102
111 };
112
113 // ========================================================================
114
127 {
136
143 std::string message;
144
153
161 };
162
163 // ========================================================================
164
209 {
210 public:
221
243 template <class Expr_T>
244 void
245 init (const Expr_T& expr, check_kind kind,
247 expression_formatter& expression, bool writes_passed);
248
256 check_result (const check_result&) = delete;
257
267
276 = delete;
277
286 = delete;
287
295 ~check_result () noexcept (false);
296
317 template <class T>
318 requires detail::message_argument<T>
320 operator<< (const T& msg) &&;
321
322#if !defined(__DOXYGEN__)
337 template <class T>
338 requires (not detail::message_argument<T>)
340 operator<<(const T& msg) &&;
341#endif // !defined(__DOXYGEN__)
342
355 [[nodiscard]] bool
356 value (void) const&& noexcept;
357
358 private:
378 void
379 start (bool value, check_kind kind, bool has_expression,
381 bool writes_passed);
382
390 bool value_ = false;
391
401 bool is_written_ = false;
402
413
424#if defined(__cpp_exceptions)
426#endif // defined(__cpp_exceptions)
427
437 };
438
439 // ------------------------------------------------------------------------
440 } // namespace detail
441
442 // --------------------------------------------------------------------------
443} // namespace micro_os_plus::micro_test_plus
444
445#if defined(__GNUC__)
446#pragma GCC diagnostic pop
447#endif // defined(__GNUC__)
448
449// ----------------------------------------------------------------------------
450
451#endif // defined(__cplusplus)
452
453// ============================================================================
454// Templates, inlines & constexpr implementations.
455
457
458// ----------------------------------------------------------------------------
459
460#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_CHECK_RESULT_H_
461
462// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.