Skip to content

Commit

Permalink
Add mistakenly dropped macro definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrahams committed Aug 17, 2024
1 parent 4f77e8f commit 1daba17
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/default_handler_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,32 @@

ADOBE_DEFAULT_CONTRACT_VIOLATION_HANDLER()

#if defined(GTEST_OS_WINDOWS) || defined(__EMSCRIPTEN__)
#if defined(__EMSCRIPTEN__)

// GoogleTest doesn't support death tests under emscripten, so instead
// we handle death by setting the test's WILL_FAIL property in CMake.
// Therefore the test simply executes the code that aborts with no
// wrapper. There's currently no facility for checking test output.

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define EXPECT_ABORT(code, expected_output_regex) code

#elif defined(GTEST_OS_WINDOWS)
// GoogleTest doesn't support checking for the abort signal on
// Windows, so we use an auxilliary file, win32_abort_detection.cpp,
// to ensure that an unusual string is printed, which we can check for
// with the EXPECT_DEATH macro.

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define EXPECT_ABORT(code, expected_output_regex) \
EXPECT_DEATH_IF_SUPPORTED(code, expected_output_regex ".*\n*##ABORTED##");
EXPECT_DEATH(code, expected_output_regex ".*\n*##ABORTED##");

#else

// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define EXPECT_ABORT(code, expected_output_regex) \
EXPECT_EXIT(code, testing::KilledBySignal(SIGABRT), expected_output_regex);

#endif

TEST(DefaultHandler, ContractNonViolationsDoNotCauseAbort)
Expand Down

0 comments on commit 1daba17

Please sign in to comment.