ExceptionWrapper: use std::decay in implicit constructor
[folly.git] / folly / test / ExceptionWrapperTest.cpp
index a12445adb514fab2e6c9cba6a8b3ab35cc592460..47b18d2ef5fbc200c01d2be0cce91cd2af1c3cc7 100644 (file)
@@ -227,3 +227,17 @@ TEST(ExceptionWrapper, exceptionStr) {
   auto ew = make_exception_wrapper<std::runtime_error>("argh");
   EXPECT_EQ("std::runtime_error: argh", exceptionStr(ew));
 }
+
+namespace {
+class TestException : public std::exception { };
+void testEW(const exception_wrapper& ew) {
+  EXPECT_THROW(ew.throwException(), TestException);
+}
+}  // namespace
+
+TEST(ExceptionWrapper, implicitConstruction) {
+  // Try with both lvalue and rvalue references
+  TestException e;
+  testEW(e);
+  testEW(TestException());
+}