Skip to main content

exceptions.h File

C++ header file with declarations for the µTest++ exception-checking functions. More...

Included Headers​

#include "detail.h" #include "inlines/exceptions-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...

Functions Index​

template <class Callable_T>
autonothrow (Callable_T &&func)

Checks whether a callable does not throw any exception, for expect() or require(). More...

template <class Callable_T>
autothrows (Callable_T &&func)

Checks whether a callable throws any exception, for expect() or require(). More...

template <class Exception_T, class Callable_T>
autothrows (Callable_T &&func)

Checks whether a callable throws a specific exception, for expect() or require(). More...

Description​

C++ header file with declarations for the µTest++ exception-checking functions.

This header provides the declarations for the exception-checking facilities of the µTest++ framework. It exposes three function templates — throws<Exception_T>(), throws(), and nothrow() — which allow test cases to verify that a callable throws a specific exception, throws any exception, or throws no exception, respectively.

All declarations are conditionally compiled under __cpp_exceptions and reside within the micro_os_plus::micro_test_plus namespace.

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

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 * 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
36
37#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_EXCEPTIONS_H_
38#define MICRO_OS_PLUS_MICRO_TEST_PLUS_EXCEPTIONS_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
54#include "detail.h"
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic push
60
61#pragma GCC diagnostic ignored "-Waggregate-return"
62#if defined(__clang__)
63#pragma clang diagnostic ignored "-Wc++98-compat"
64#endif // defined(__clang__)
65#endif // defined(__GNUC__)
66
67// ============================================================================
68
70{
71 // --------------------------------------------------------------------------
72
73#if defined(__cpp_exceptions)
74
96 template <class Exception_T, class Callable_T>
97 requires std::invocable<Callable_T&>
98 [[nodiscard]] auto
99 throws (Callable_T&& func);
100
118 template <class Callable_T>
119 requires std::invocable<Callable_T&>
120 [[nodiscard]] auto
121 throws (Callable_T&& func);
122
135 template <class Callable_T>
136 requires std::invocable<Callable_T&>
137 [[nodiscard]] auto
138 nothrow (Callable_T&& func);
139
140#endif // defined(__cpp_exceptions)
141
142 // --------------------------------------------------------------------------
143} // namespace micro_os_plus::micro_test_plus
144
145#if defined(__GNUC__)
146#pragma GCC diagnostic pop
147#endif // defined(__GNUC__)
148
149// ----------------------------------------------------------------------------
150
151#endif // defined(__cplusplus)
152
153// ============================================================================
154// Templates, inlines & constexpr implementations.
155
157
158// ----------------------------------------------------------------------------
159
160#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_EXCEPTIONS_H_
161
162// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.