From 58666935987bf760f55ecb1ff33c57b238654a4a Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Mon, 5 Feb 2024 15:28:35 +0100 Subject: [PATCH] iox-#1032 Adjust error detection condition in fatal failure test function --- .../include/iceoryx_hoofs/testing/fatal_failure.inl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl index 5f54a28f76..cf51733107 100644 --- a/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl +++ b/iceoryx_hoofs/testing/include/iceoryx_hoofs/testing/fatal_failure.inl @@ -33,11 +33,12 @@ inline bool IOX_EXPECT_FATAL_FAILURE(const function_ref testFunction, iox::testing::ErrorHandler::instance().reset(); runInTestThread([&] { testFunction(); }); IOX_TESTING_EXPECT_PANIC(); + auto hasPanicked = iox::testing::hasPanicked(); auto hasExpectedError{false}; if constexpr (std::is_same_v) { - hasExpectedError = iox::testing::hasPanicked(); + hasExpectedError = hasPanicked; if (!hasExpectedError) { IOX_LOG(ERROR, "Expected '" << iox::er::FatalKind::name << "' but it did not happen!"); @@ -45,7 +46,7 @@ inline bool IOX_EXPECT_FATAL_FAILURE(const function_ref testFunction, } else if constexpr (std::is_same_v) { - hasExpectedError = iox::testing::hasEnforceViolation() && iox::testing::hasPanicked(); + hasExpectedError = iox::testing::hasEnforceViolation(); if (!hasExpectedError) { IOX_LOG(ERROR, "Expected '" << iox::er::EnforceViolationKind::name << "' but it did not happen!"); @@ -53,7 +54,7 @@ inline bool IOX_EXPECT_FATAL_FAILURE(const function_ref testFunction, } else if constexpr (std::is_same_v) { - hasExpectedError = iox::testing::hasAssertViolation() && iox::testing::hasPanicked(); + hasExpectedError = iox::testing::hasAssertViolation(); if (!hasExpectedError) { IOX_LOG(ERROR, "Expected '" << iox::er::AssertViolationKind::name << "' but it did not happen!"); @@ -61,7 +62,7 @@ inline bool IOX_EXPECT_FATAL_FAILURE(const function_ref testFunction, } else { - hasExpectedError = iox::testing::hasError(expectedError) && iox::testing::hasPanicked(); + hasExpectedError = iox::testing::hasError(expectedError); if (!hasExpectedError) { IOX_LOG(ERROR, "Expected an '" << expectedError << "' error but it did not happen!"); @@ -69,7 +70,7 @@ inline bool IOX_EXPECT_FATAL_FAILURE(const function_ref testFunction, } EXPECT_TRUE(hasExpectedError); - return hasExpectedError; + return hasExpectedError && hasPanicked; } inline bool IOX_EXPECT_NO_FATAL_FAILURE(const function_ref testFunction)