![]() |
micro-test-plus 3.2.2
µTest++ Testing Framework
|
Functions for verifying exceptions in test cases. More...
Functions | |
template<class Callable_T> | |
constexpr auto | micro_os_plus::micro_test_plus::nothrow (const Callable_T &func) |
Check if a callable does not throw an exception. | |
template<class Exception_T, class Callable_T> | |
constexpr auto | micro_os_plus::micro_test_plus::throws (const Callable_T &func) |
Check if a callable throws a specific exception. | |
template<class Callable_T> | |
constexpr auto | micro_os_plus::micro_test_plus::throws (const Callable_T &func) |
Check if a callable throws an exception (any exception). |
The µTest++ framework provides dedicated functions for verifying whether specific expressions or function calls throw exceptions, supporting robust testing of error handling and exceptional conditions in C++ code.
These utilities enable developers to assert that exceptions are correctly thrown or not thrown as expected, improving the reliability and safety of software components. The framework supports both generic exception checks and type-specific exception verification, allowing for precise and expressive test cases.
For more advanced scenarios, such as handling multiple expected exceptions, developers can use explicit try blocks with multiple catch statements and report the results using expect(true) or expect(false). This approach ensures comprehensive coverage of exception handling logic.
If more advanced logic is required, such as handling multiple expected exceptions, use an explicit try block with several catch statements, and report the outcomes using expect(true) or expect(false).
|
nodiscardconstexpr |
Callable_T | The type of the callable object to be invoked. |
[in] | func | The callable object to check for exception safety. |
The nothrow function template verifies whether invoking the provided callable object does not result in the throwing of any exception within the µTest++ framework. This is useful for testing exception safety and ensuring that code under test does not unexpectedly signal error conditions.
The function returns an output stream, allowing optional messages to be appended to the test report for diagnostic purposes.
Definition at line 242 of file micro-test-plus-inlines.h.
|
nodiscardconstexpr |
Exception_T | The type of the exception expected to be thrown. |
Callable_T | The type of the callable object to be invoked. |
[in] | func | The callable object to check for exception throwing behaviour. |
The throws function template verifies whether invoking the provided callable object results in the throwing of a specific exception type within the µTest++ framework. This is useful for testing error handling and exception safety in code under test.
The function returns an output stream, allowing optional messages to be appended to the test report for diagnostic purposes.
Definition at line 207 of file micro-test-plus-inlines.h.
|
nodiscardconstexpr |
Callable_T | The type of the callable object to be invoked. |
[in] | func | The callable object to check for exception throwing behaviour. |
The throws function template verifies whether invoking the provided callable object results in the throwing of any exception within the µTest++ framework. This is useful for testing general exception safety and ensuring that code under test properly signals error conditions.
The function returns an output stream, allowing optional messages to be appended to the test report for diagnostic purposes.
Definition at line 224 of file micro-test-plus-inlines.h.