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
EXPECT_FALSE(ew.has_exception_ptr());
EXPECT_NE(nullptr, ew.to_exception_ptr());
EXPECT_TRUE(ew.has_exception_ptr());
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>());
EXPECT_TRUE(ew.is_compatible_with<std::exception>());
EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
EXPECT_FALSE(ew.is_compatible_with<int>());
EXPECT_TRUE(ew.has_exception_ptr());
EXPECT_EQ(ep, ew.to_exception_ptr());
EXPECT_TRUE(ew.has_exception_ptr());
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>());
EXPECT_TRUE(ew.is_compatible_with<std::exception>());
EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
EXPECT_FALSE(ew.is_compatible_with<int>());
TEST(ExceptionWrapper, self_swap_test) {
exception_wrapper ew(std::runtime_error("hello world"));
folly::swap(ew, ew);
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
}
auto& ew2 = ew;
ew = std::move(ew2); // should not crash
}