iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
iox2::bb::testing::TestingErrorHandler Class Reference

Defines the test reaction of dynamic error handling. More...

#include <testing_error_handler.hpp>

Inheritance diagram for iox2::bb::testing::TestingErrorHandler:
iox2::legacy::er::ErrorHandlerInterface

Public Member Functions

 TestingErrorHandler () noexcept=default
 
 ~TestingErrorHandler () noexcept override=default
 
 TestingErrorHandler (const TestingErrorHandler &) noexcept=delete
 
 TestingErrorHandler (TestingErrorHandler &&) noexcept=delete
 
auto operator= (const TestingErrorHandler &) noexcept -> TestingErrorHandler &=delete
 
auto operator= (TestingErrorHandler &&) noexcept -> TestingErrorHandler=delete
 
auto on_panic () -> void override
 Defines the reaction on panic.
 
auto on_report_error (legacy::er::ErrorDescriptor desc) -> void override
 Defines the reaction on error.
 
auto on_report_violation (legacy::er::ErrorDescriptor desc) -> void override
 Defines the reaction on violation.
 
auto has_panicked () const noexcept -> bool
 Indicates whether there was a panic call previously.
 
auto reset () noexcept -> void
 Reset panic state and clears all errors that occurred previously.
 
auto has_error () const noexcept -> bool
 Indicates whether any error occurred previously.
 
auto has_error (legacy::er::ErrorCode code, legacy::er::ModuleId module=legacy::er::ModuleId()) const noexcept -> bool
 Indicates whether a specific error occurred previously.
 
auto has_violation (legacy::er::ErrorCode code) const noexcept -> bool
 Indicates whether a assumption violation occurred previously.
 
auto fatal_failure_test_context (const bb::StaticFunction< void()> &test_function) -> bool
 runs test_function in a test context that can detect fatal failures; runs in the same thread
 
- Public Member Functions inherited from iox2::legacy::er::ErrorHandlerInterface
virtual ~ErrorHandlerInterface ()=default
 

Static Public Member Functions

static auto init () noexcept -> void
 Initialized the error handler. This should be called in the main function of the test binary.
 

Detailed Description

Defines the test reaction of dynamic error handling.

Definition at line 41 of file testing_error_handler.hpp.

Constructor & Destructor Documentation

◆ TestingErrorHandler() [1/3]

iox2::bb::testing::TestingErrorHandler::TestingErrorHandler ( )
defaultnoexcept

◆ ~TestingErrorHandler()

iox2::bb::testing::TestingErrorHandler::~TestingErrorHandler ( )
overridedefaultnoexcept

◆ TestingErrorHandler() [2/3]

iox2::bb::testing::TestingErrorHandler::TestingErrorHandler ( const TestingErrorHandler )
deletenoexcept

◆ TestingErrorHandler() [3/3]

iox2::bb::testing::TestingErrorHandler::TestingErrorHandler ( TestingErrorHandler &&  )
deletenoexcept

Member Function Documentation

◆ fatal_failure_test_context()

auto iox2::bb::testing::TestingErrorHandler::fatal_failure_test_context ( const bb::StaticFunction< void()> &  test_function) -> bool
inline

runs test_function in a test context that can detect fatal failures; runs in the same thread

Note
uses setjmp/longjmp

Definition at line 139 of file testing_error_handler.hpp.

References iox2::legacy::concurrent::Atomic< T >::exchange().

◆ has_error() [1/2]

auto iox2::bb::testing::TestingErrorHandler::has_error ( ) const -> bool
inlinenoexcept

Indicates whether any error occurred previously.

Definition at line 102 of file testing_error_handler.hpp.

◆ has_error() [2/2]

auto iox2::bb::testing::TestingErrorHandler::has_error ( legacy::er::ErrorCode  code,
legacy::er::ModuleId  module = legacy::er::ModuleId() 
) const -> bool
inlinenoexcept

Indicates whether a specific error occurred previously.

Definition at line 108 of file testing_error_handler.hpp.

References iox2::legacy::er::ModuleId::ANY.

◆ has_panicked()

auto iox2::bb::testing::TestingErrorHandler::has_panicked ( ) const -> bool
inlinenoexcept

Indicates whether there was a panic call previously.

Returns
true if there was a panic call, false otherwise

Definition at line 88 of file testing_error_handler.hpp.

References iox2::legacy::concurrent::Atomic< T >::load().

◆ has_violation()

auto iox2::bb::testing::TestingErrorHandler::has_violation ( legacy::er::ErrorCode  code) const -> bool
inlinenoexcept

Indicates whether a assumption violation occurred previously.

Note
We do not track module id for violations.

Definition at line 125 of file testing_error_handler.hpp.

◆ init()

auto iox2::bb::testing::TestingErrorHandler::init ( ) -> void
inlinestaticnoexcept

Initialized the error handler. This should be called in the main function of the test binary.

#include "test.hpp"
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
bb::testing::ErrorHandler::init();
return RUN_ALL_TESTS();
}

Definition at line 201 of file testing_error_handler.hpp.

References iox2::legacy::PolymorphicHandler< Interface, Default, Hooks >::set().

◆ on_panic()

auto iox2::bb::testing::TestingErrorHandler::on_panic ( ) -> void
inlineoverridevirtual

Defines the reaction on panic.

Implements iox2::legacy::er::ErrorHandlerInterface.

Definition at line 67 of file testing_error_handler.hpp.

◆ on_report_error()

auto iox2::bb::testing::TestingErrorHandler::on_report_error ( legacy::er::ErrorDescriptor  desc) -> void
inlineoverridevirtual

Defines the reaction on error.

Parameters
descerror descriptor

Implements iox2::legacy::er::ErrorHandlerInterface.

Definition at line 74 of file testing_error_handler.hpp.

◆ on_report_violation()

auto iox2::bb::testing::TestingErrorHandler::on_report_violation ( legacy::er::ErrorDescriptor  desc) -> void
inlineoverridevirtual

Defines the reaction on violation.

Parameters
descerror descriptor

Implements iox2::legacy::er::ErrorHandlerInterface.

Definition at line 81 of file testing_error_handler.hpp.

◆ operator=() [1/2]

auto iox2::bb::testing::TestingErrorHandler::operator= ( const TestingErrorHandler ) -> TestingErrorHandler &=delete
deletenoexcept

◆ operator=() [2/2]

auto iox2::bb::testing::TestingErrorHandler::operator= ( TestingErrorHandler &&  ) -> TestingErrorHandler=delete
deletenoexcept

◆ reset()

auto iox2::bb::testing::TestingErrorHandler::reset ( ) -> void
inlinenoexcept

Reset panic state and clears all errors that occurred previously.

Definition at line 93 of file testing_error_handler.hpp.

References iox2::legacy::concurrent::Atomic< T >::store().


The documentation for this class was generated from the following file: