Skip to content

Commit d3bb275

Browse files
authored
Fix source location test failure resulting from newer compiler (#1326)
1 parent ec54c40 commit d3bb275

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/test_cpp20/custom_error.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ TEST_CASE("custom_error_logger")
6161
REQUIRE(fileNameSv.find("custom_error.cpp") != std::string::npos);
6262
const auto functionNameSv = std::string_view(s_loggerArgs.functionName);
6363
REQUIRE(!functionNameSv.empty());
64-
#if defined(__GNUC__) && !defined(__clang__)
65-
REQUIRE(functionNameSv == "void {anonymous}::FailOnLine15()");
66-
#elif defined(__GNUC__) && defined(__clang__)
67-
REQUIRE(functionNameSv == "void (anonymous namespace)::FailOnLine15()");
68-
#else
69-
REQUIRE(functionNameSv == "FailOnLine15");
70-
#endif
64+
// Every compiler has a slightly different naming approach for this function, and even the same
65+
// compiler can change its mind over time. Instead of matching the entire function name just
66+
// match against the part we care about.
67+
REQUIRE((functionNameSv.find("FailOnLine15") != std::string_view::npos));
7168

7269
REQUIRE(s_loggerArgs.returnAddress);
7370
REQUIRE(s_loggerArgs.result == static_cast<int32_t>(0x80000018)); // E_ILLEGAL_DELEGATE_ASSIGNMENT)

0 commit comments

Comments
 (0)