14#ifndef IOX2_BB_TESTING_FATAL_FAILURE_HPP
15#define IOX2_BB_TESTING_FATAL_FAILURE_HPP
24#include <gmock/gmock.h>
25#include <gtest/gtest.h>
43template <
typename ErrorType,
44 std::enable_if_t<!std::is_same<ErrorType, legacy::er::FatalKind>::value
45 && !std::is_same<ErrorType, legacy::er::EnforceViolationKind>::value
46 && !std::is_same<ErrorType, legacy::er::AssertViolationKind>::value,
55 const auto has_expected_error =
has_error(expected_error);
56 if (!has_expected_error) {
57 IOX2_LOG(
Error,
"Expected an '" << expected_error <<
"' error but it did not happen!");
60 EXPECT_TRUE(has_expected_error);
64template <typename ErrorType, std::enable_if_t<std::is_same<ErrorType, legacy::er::FatalKind>::value,
bool> =
true>
73 if (!has_expected_error) {
77 EXPECT_TRUE(has_expected_error);
81template <
typename ErrorType,
82 std::enable_if_t<std::is_same<ErrorType, legacy::er::EnforceViolationKind>::value,
bool> =
true>
91 if (!has_expected_error) {
95 EXPECT_TRUE(has_expected_error);
99template <
typename ErrorType,
100 std::enable_if_t<std::is_same<ErrorType, legacy::er::AssertViolationKind>::value,
bool> =
true>
109 if (!has_expected_error) {
113 EXPECT_TRUE(has_expected_error);
140#define IOX2_TESTING_EXPECT_FATAL_FAILURE(test_function, expected_error) \
141 iox2::bb::testing::expect_fatal_failure(test_function, expected_error)
143#define IOX2_TESTING_EXPECT_NO_FATAL_FAILURE(test_function) iox2::bb::testing::expect_no_fatal_failure(test_function)
#define IOX2_MAYBE_UNUSED
IOX2_MAYBE_UNUSED adds the [[gnu::unused]] attribute when it is available for the current compiler or...
static T & instance(Args &&... args) noexcept
Construct the instance to be guarded with constructor arguments.
#define IOX2_LOG(level, msg_stream)
Macro for logging.
auto has_panicked() -> bool
indicates whether the test error handler invoked panic
auto expect_no_fatal_failure(const bb::StaticFunction< void()> &test_function) -> bool
This function is used in cases no fatal failure is expected but could potentially occur....
auto expect_fatal_failure(const bb::StaticFunction< void()> &test_function, const ErrorType expected_error) -> bool
This function is used in cases a fatal failure is expected. The function only works in combination wi...
auto has_assert_violation() -> bool
indicates whether the test error handler registered an assert violation
auto has_error() -> bool
indicates whether the test error handler registered any error
auto run_in_test_thread(const bb::StaticFunction< void()> test_function) -> void
runs test_function in a test context that can detect fatal failures; runs in a separate thread
auto has_enforce_violation() -> bool
indicates whether the test error handler registered an enforce violation
detail::StaticFunction< Capacity, Signature > StaticFunction
A static memory replacement for std::function.
static constexpr char const * name
static constexpr char const * name
static constexpr char const * name
#define IOX2_TESTING_EXPECT_PANIC()