From dd707e05ecc7c3a9271bb8d94d0a2ad2ef27821a Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Sun, 18 Jun 2017 11:14:46 -0700 Subject: [PATCH] Fix a few exception_wrapper tests under MSVC Summary: They were incorrectly comparing against string literals rather than the actual demangled names. MSVC includes `class/struct` as part of the mangled name, so they also appear in the demangled name, in contrast to GCC/Clang, which don't. Reviewed By: yfeldblum Differential Revision: D5271087 fbshipit-source-id: 41fa0cebe098b1b935e1f8b1af5882c412cf6254 --- folly/test/ExceptionWrapperTest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/folly/test/ExceptionWrapperTest.cpp b/folly/test/ExceptionWrapperTest.cpp index 58a32a17..36f7298f 100644 --- a/folly/test/ExceptionWrapperTest.cpp +++ b/folly/test/ExceptionWrapperTest.cpp @@ -236,8 +236,8 @@ TEST(ExceptionWrapper, with_shared_ptr_test) { EXPECT_FALSE(ew.has_exception_ptr()); EXPECT_NE(nullptr, ew.to_exception_ptr()); EXPECT_TRUE(ew.has_exception_ptr()); - EXPECT_EQ("std::runtime_error", ew.class_name()); - EXPECT_EQ("std::runtime_error: foo", ew.what()); + EXPECT_EQ(kRuntimeErrorClassName, ew.class_name()); + EXPECT_EQ(kRuntimeErrorClassName + ": foo", ew.what()); EXPECT_TRUE(ew.is_compatible_with()); EXPECT_TRUE(ew.is_compatible_with()); EXPECT_FALSE(ew.is_compatible_with()); @@ -268,8 +268,8 @@ TEST(ExceptionWrapper, with_exception_ptr_exn_test) { EXPECT_TRUE(ew.has_exception_ptr()); EXPECT_EQ(ep, ew.to_exception_ptr()); EXPECT_TRUE(ew.has_exception_ptr()); - EXPECT_EQ("std::runtime_error", ew.class_name()); - EXPECT_EQ("std::runtime_error: foo", ew.what()); + EXPECT_EQ(kRuntimeErrorClassName, ew.class_name()); + EXPECT_EQ(kRuntimeErrorClassName + ": foo", ew.what()); EXPECT_TRUE(ew.is_compatible_with()); EXPECT_TRUE(ew.is_compatible_with()); EXPECT_FALSE(ew.is_compatible_with()); @@ -742,7 +742,7 @@ TEST(ExceptionWrapper, handle_non_std_exception_rethrow_base_derived) { TEST(ExceptionWrapper, self_swap_test) { exception_wrapper ew(std::runtime_error("hello world")); folly::swap(ew, ew); - EXPECT_STREQ("std::runtime_error: hello world", ew.what().c_str()); + EXPECT_EQ(kRuntimeErrorClassName + ": hello world", ew.what()); auto& ew2 = ew; ew = std::move(ew2); // should not crash } -- 2.34.1