14#ifndef IOX2_BB_TESTING_ERROR_REPORTING_TESTING_SUPPORT_HPP
15#define IOX2_BB_TESTING_ERROR_REPORTING_TESTING_SUPPORT_HPP
17#include <gtest/gtest.h>
30template <
typename Code>
72 auto thread = std::thread([&]() ->
auto {
74 if (!successfull_run) {
75 GTEST_FAIL() <<
"This should not fail! Incorrect usage!";
79 if (thread.joinable()) {
94#define IOX2_TESTING_ASSERT_OK() ASSERT_TRUE(iox2::bb::testing::is_in_normal_state())
96#define IOX2_TESTING_ASSERT_NO_PANIC() ASSERT_FALSE(iox2::bb::testing::has_panicked())
98#define IOX2_TESTING_ASSERT_PANIC() ASSERT_TRUE(iox2::bb::testing::has_panicked())
100#define IOX2_TESTING_ASSERT_ERROR(code) ASSERT_TRUE(iox2::bb::testing::has_error(code))
102#define IOX2_TESTING_ASSERT_NO_ERROR() ASSERT_FALSE(iox2::bb::testing::has_error())
104#define IOX2_TESTING_ASSERT_VIOLATION() ASSERT_TRUE(iox2::bb::testing::has_violation())
106#define IOX2_TESTING_ASSERT_NO_VIOLATION() ASSERT_FALSE(iox2::bb::testing::has_violation())
108#define IOX2_TESTING_ASSERT_ASSERT_VIOLATION() ASSERT_TRUE(iox2::bb::testing::has_assert_violation())
110#define IOX2_TESTING_ASSERT_ENFORCE_VIOLATION() ASSERT_TRUE(iox2::bb::testing::has_enforce_violation())
114#define IOX2_TESTING_EXPECT_OK() EXPECT_TRUE(iox2::bb::testing::is_in_normal_state())
116#define IOX2_TESTING_EXPECT_NO_PANIC() EXPECT_FALSE(iox2::bb::testing::has_panicked())
118#define IOX2_TESTING_EXPECT_PANIC() EXPECT_TRUE(iox2::bb::testing::has_panicked())
120#define IOX2_TESTING_EXPECT_ERROR(code) EXPECT_TRUE(iox2::bb::testing::has_error(code))
122#define IOX2_TESTING_EXPECT_NO_ERROR() EXPECT_FALSE(iox2::bb::testing::has_error())
124#define IOX2_TESTING_EXPECT_VIOLATION() EXPECT_TRUE(iox2::bb::testing::has_violation())
126#define IOX2_TESTING_EXPECT_NO_VIOLATION() EXPECT_FALSE(iox2::bb::testing::has_violation())
128#define IOX2_TESTING_EXPECT_ASSERT_VIOLATION() EXPECT_TRUE(iox2::bb::testing::has_assert_violation())
130#define IOX2_TESTING_EXPECT_ENFORCE_VIOLATION() EXPECT_TRUE(iox2::bb::testing::has_enforce_violation())
static T & instance(Args &&... args) noexcept
Construct the instance to be guarded with constructor arguments.
auto is_in_normal_state() -> bool
indicates there is no error, violation or panic.
auto has_violation() -> bool
indicates whether the test error handler registered violation (there are only two kinds).
auto has_panicked() -> bool
indicates whether the test error handler invoked panic
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
constexpr auto err(const E &error) -> Unexpected< E >
HoofsErrorType toError(HoofsError code)