| 42 | } |
| 43 | |
| 44 | int main() |
| 45 | { |
| 46 | { |
| 47 | e_my_error e = { my_error::e1 }; |
| 48 | |
| 49 | BOOST_TEST(( test<leaf::match_value<e_my_error, my_error::e1>>(e) )); |
| 50 | BOOST_TEST(( !test<leaf::match_value<e_my_error, my_error::e2>>(e) )); |
| 51 | BOOST_TEST(( test<leaf::match_value<e_my_error, my_error::e2, my_error::e1>>(e) )); |
| 52 | } |
| 53 | |
| 54 | #if BOOST_LEAF_CFG_STD_SYSTEM_ERROR |
| 55 | { |
| 56 | e_error_code e = { errc_a::a0 }; |
| 57 | |
| 58 | BOOST_TEST(( test<leaf::match_value<leaf::condition<e_error_code, cond_x>, cond_x::x00>>(e) )); |
| 59 | BOOST_TEST(( !test<leaf::match_value<leaf::condition<e_error_code, cond_x>, cond_x::x11>>(e) )); |
| 60 | BOOST_TEST(( test<leaf::match_value<leaf::condition<e_error_code, cond_x>, cond_x::x11, cond_x::x00>>(e) )); |
| 61 | |
| 62 | #if __cplusplus >= 201703L |
| 63 | BOOST_TEST(( test<leaf::match_value<e_error_code, errc_a::a0>>(e) )); |
| 64 | BOOST_TEST(( !test<leaf::match_value<e_error_code, errc_a::a2>>(e) )); |
| 65 | BOOST_TEST(( test<leaf::match_value<e_error_code, errc_a::a2, errc_a::a0>>(e) )); |
| 66 | #endif |
| 67 | } |
| 68 | #endif |
| 69 | |
| 70 | { |
| 71 | int r = leaf::try_handle_all( |
| 72 | []() -> leaf::result<int> |
| 73 | { |
| 74 | return leaf::new_error(e_my_error{my_error::e1}); |
| 75 | }, |
| 76 | |
| 77 | []( leaf::match_value<e_my_error, my_error::e1> ) |
| 78 | { |
| 79 | return 1; |
| 80 | }, |
| 81 | |
| 82 | [] |
| 83 | { |
| 84 | return 2; |
| 85 | } ); |
| 86 | BOOST_TEST_EQ(r, 1); |
| 87 | } |
| 88 | |
| 89 | { |
| 90 | int r = leaf::try_handle_all( |
| 91 | []() -> leaf::result<int> |
| 92 | { |
| 93 | return leaf::new_error(e_my_error{my_error::e1}); |
| 94 | }, |
| 95 | |
| 96 | []( leaf::match_value<e_my_error, my_error::e2> ) |
| 97 | { |
| 98 | return 1; |
| 99 | }, |
| 100 | |
| 101 | [] |
nothing calls this directly
no test coverage detected