Skip to content

Commit 2b4c984

Browse files
committed
Fixed spurious leaks detected on MSVC
1 parent 388a3b9 commit 2b4c984

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/runtime_tests.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ std::size_t double_delete = 0u;
1414
bool memory_tracking = false;
1515
bool force_next_allocation_failure = false;
1616

17+
// Replace Catch2's REQUIRE_THROWS_AS, which allocates on Windows;
18+
// this confuses our memory leak checks.
19+
#undef REQUIRE_THROWS_AS
20+
#define REQUIRE_THROWS_AS(EXPRESSION, EXCEPTION) \
21+
do { \
22+
try { \
23+
EXPRESSION; \
24+
FAIL("no exception thrown"); \
25+
} catch (const EXCEPTION&) { \
26+
} catch (...) { \
27+
FAIL("unexpected exception thrown"); \
28+
} \
29+
} while (0)
30+
1731
#define CHECK_MEMORY_LEAKS 1
1832

1933
#if defined(CHECK_MEMORY_LEAKS) && CHECK_MEMORY_LEAKS

0 commit comments

Comments
 (0)