Fix a few exception_wrapper tests under MSVC
authorChristopher Dykes <cdykes@fb.com>
Sun, 18 Jun 2017 18:14:46 +0000 (11:14 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 18 Jun 2017 18:20:34 +0000 (11:20 -0700)
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

index 58a32a1..36f7298 100644 (file)
@@ -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<std::exception>());
   EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
   EXPECT_FALSE(ew.is_compatible_with<int>());
@@ -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<std::exception>());
   EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
   EXPECT_FALSE(ew.is_compatible_with<int>());
@@ -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
 }