iceoryx2
C++ 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
virtual void on_panic ()=0
 Defines the reaction on panic.
virtual void on_report_error (ErrorDescriptor desc)=0
 Defines the reaction on error.
virtual void on_report_violation (ErrorDescriptor desc)=0
 Defines the reaction on violation (a bug in the code).

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

References TestingErrorHandler().

◆ TestingErrorHandler() [2/3]

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

References TestingErrorHandler().

◆ TestingErrorHandler() [3/3]

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

References TestingErrorHandler().

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.

Referenced by iox2::bb::testing::run_in_test_thread().

◆ 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.

Referenced by iox2::bb::testing::has_error(), and iox2::bb::testing::has_error().

◆ 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.

Referenced by iox2::bb::testing::has_panicked().

◆ 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.

Referenced by iox2::bb::testing::has_assert_violation(), and iox2::bb::testing::has_enforce_violation().

◆ 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< ErrorHandlerInterface, DefaultErrorHandler >::set().

Referenced by operator=().

◆ on_panic()

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

Defines the reaction on panic.

Definition at line 67 of file testing_error_handler.hpp.

References on_panic().

Referenced by on_panic().

◆ on_report_error()

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

Defines the reaction on error.

Parameters
descerror descriptor

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
inlineoverride

Defines the reaction on violation.

Parameters
descerror descriptor

Definition at line 81 of file testing_error_handler.hpp.

◆ operator=() [1/2]

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

References TestingErrorHandler().

◆ operator=() [2/2]

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

References init(), and TestingErrorHandler().

◆ 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.

Referenced by iox2::bb::testing::expect_fatal_failure(), and iox2::bb::testing::expect_fatal_failure().


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