| 55 | #endif // #if BOOST_LEAF_CFG_STD_SYSTEM_ERROR |
| 56 | |
| 57 | int main() |
| 58 | { |
| 59 | // void, try_handle_some (success) |
| 60 | { |
| 61 | int c=0; |
| 62 | leaf::result<void> r = leaf::try_handle_some( |
| 63 | [&c]() -> leaf::result<void> |
| 64 | { |
| 65 | BOOST_LEAF_AUTO(answer, f<int>(my_error_code::ok)); |
| 66 | c = answer; |
| 67 | return { }; |
| 68 | }, |
| 69 | [&c]( leaf::error_info const & unmatched ) |
| 70 | { |
| 71 | BOOST_TEST_EQ(c, 0); |
| 72 | c = 1; |
| 73 | return unmatched.error(); |
| 74 | } ); |
| 75 | BOOST_TEST(r); |
| 76 | BOOST_TEST_EQ(c, 42); |
| 77 | } |
| 78 | |
| 79 | // void, try_handle_some (failure, matched) |
| 80 | { |
| 81 | int c=0; |
| 82 | leaf::result<void> r = leaf::try_handle_some( |
| 83 | [&c]() -> leaf::result<void> |
| 84 | { |
| 85 | BOOST_LEAF_AUTO(answer, f<int>(my_error_code::error1)); |
| 86 | c = answer; |
| 87 | return { }; |
| 88 | }, |
| 89 | [&c]( my_error_code ec, info<1> const & x, info<2> y ) |
| 90 | { |
| 91 | BOOST_TEST(ec == my_error_code::error1); |
| 92 | BOOST_TEST_EQ(x.value, 1); |
| 93 | BOOST_TEST_EQ(y.value, 2); |
| 94 | BOOST_TEST_EQ(c, 0); |
| 95 | c = 1; |
| 96 | } ); |
| 97 | BOOST_TEST_EQ(c, 1); |
| 98 | BOOST_TEST(r); |
| 99 | } |
| 100 | |
| 101 | #if BOOST_LEAF_CFG_STD_SYSTEM_ERROR |
| 102 | // void, try_handle_some (failure, matched), match cond_x (single enum value) |
| 103 | { |
| 104 | int c=0; |
| 105 | leaf::result<void> r = leaf::try_handle_some( |
| 106 | [&c]() -> leaf::result<void> |
| 107 | { |
| 108 | BOOST_LEAF_AUTO(answer, f_errc<int>(errc_a::a0)); |
| 109 | c = answer; |
| 110 | return { }; |
| 111 | }, |
| 112 | [&c]( leaf::match<leaf::condition<cond_x>, cond_x::x00> ec, info<1> const & x, info<2> const & y ) |
| 113 | { |
| 114 | BOOST_TEST_EQ(ec.matched, make_error_code(errc_a::a0)); |
nothing calls this directly
no test coverage detected