Skip to main content

exceptions.h File

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

Included Headers

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>
constexpr autonothrow (const Callable_T &func)

Check if a callable does not throw an exception. More...

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

Check if a callable throws an exception (any exception). More...

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

Check if a callable throws a specific exception. More...

Description

C++ header 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, ensuring clear separation from user code and minimising the risk of naming conflicts.

This header is located in the top-level include/micro-os-plus folder. Users should include <micro-os-plus/micro-test-plus.h> rather than this header directly.

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 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
38
39#ifndef MICRO_TEST_PLUS_EXCEPTIONS_H_
40#define MICRO_TEST_PLUS_EXCEPTIONS_H_
41
42// ----------------------------------------------------------------------------
43
44#ifdef __cplusplus
45
46// ----------------------------------------------------------------------------
47
48#if defined(__GNUC__)
49#pragma GCC diagnostic push
50#pragma GCC diagnostic ignored "-Waggregate-return"
51#if defined(__clang__)
52#pragma clang diagnostic ignored "-Wc++98-compat"
53#endif
54#endif
55
56// ============================================================================
57
59{
60 // --------------------------------------------------------------------------
61
62#if defined(__cpp_exceptions)
63
74 template <class Exception_T, class Callable_T>
75 [[nodiscard]] constexpr auto
76 throws (const Callable_T& func);
77
87 template <class Callable_T>
88 [[nodiscard]] constexpr auto
89 throws (const Callable_T& func);
90
99 template <class Callable_T>
100 [[nodiscard]] constexpr auto
101 nothrow (const Callable_T& func);
102
103#endif
104
105 // --------------------------------------------------------------------------
106} // namespace micro_os_plus::micro_test_plus
107
108#if defined(__GNUC__)
109#pragma GCC diagnostic pop
110#endif
111
112// ----------------------------------------------------------------------------
113
114#endif // __cplusplus
115
116// ============================================================================
117// Templates & constexpr implementations.
118
120
121// ----------------------------------------------------------------------------
122
123#endif // MICRO_TEST_PLUS_EXCEPTIONS_H_
124
125// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.