@@ -876,6 +876,47 @@ RESULT_CO_TEST_F(ResultTest, check_TEST_F) {
876876 EXPECT_EQ (co_await std::ref (r), 42 );
877877}
878878
879+ TEST (Result, catch_all_returns_result_error) {
880+ auto res = []() -> result<uint8_t > {
881+ return result_catch_all ([]() -> result<uint8_t > {
882+ return make_exception_wrapper<std::logic_error>(" bop" );
883+ });
884+ }();
885+ ASSERT_STREQ (" bop" , get_exception<std::logic_error>(res)->what ());
886+ }
887+
888+ TEST (Result, catch_all_throws_error) {
889+ auto res = []() -> result<uint8_t > {
890+ return result_catch_all ([]() -> uint8_t {
891+ throw std::logic_error (" foobar" );
892+ });
893+ }();
894+ ASSERT_STREQ (" foobar" , get_exception<std::logic_error>(res)->what ());
895+ }
896+
897+ TEST (Result, catch_all_throws_error_returns_result) {
898+ auto res = []() -> result<uint8_t > {
899+ return result_catch_all ([]() -> result<uint8_t > {
900+ throw std::logic_error (" foobar" );
901+ });
902+ }();
903+ ASSERT_STREQ (" foobar" , get_exception<std::logic_error>(res)->what ());
904+ }
905+
906+ TEST (Result, catch_all_void_throws_error) {
907+ auto res = []() -> result<> {
908+ return result_catch_all ([]() { throw std::logic_error (" baz" ); });
909+ }();
910+ ASSERT_STREQ (" baz" , get_exception<std::logic_error>(res)->what ());
911+ }
912+
913+ TEST (Result, catch_all_returns_value) {
914+ auto fn = []() -> result<uint8_t > {
915+ return result_catch_all ([]() -> uint8_t { return 129 ; });
916+ };
917+ ASSERT_EQ (129 , fn ().value_or_throw ());
918+ }
919+
879920} // namespace folly
880921
881922#endif // FOLLY_HAS_RESULT
0 commit comments