MCPcopy Create free account
hub / github.com/boostorg/leaf / test

Function test

test/capture_exception_result_unload_test.cpp:36–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35template <class F>
36void test( F f )
37{
38 {
39 int c=0;
40 auto r = f();
41 leaf::try_handle_all(
42 [&r]() -> leaf::result<void>
43 {
44 BOOST_LEAF_CHECK(std::move(r));
45 return { };
46 },
47 [&c]( info<1> const & x )
48 {
49 BOOST_TEST_EQ(x.value, 1);
50 BOOST_TEST_EQ(c, 0);
51 c = 1;
52 },
53 [&c]
54 {
55 BOOST_TEST_EQ(c, 0);
56 c = 2;
57 } );
58 BOOST_TEST_EQ(c, 1);
59 }
60
61 {
62 int c=0;
63 auto r = f();
64 leaf::try_handle_all(
65 [&r]() -> leaf::result<void>
66 {
67 BOOST_LEAF_CHECK(std::move(r));
68 return { };
69 },
70 [&c]( info<2> const & x )
71 {
72 BOOST_TEST_EQ(x.value, 2);
73 BOOST_TEST_EQ(c, 0);
74 c = 1;
75 },
76 [&c]
77 {
78 BOOST_TEST_EQ(c, 0);
79 c = 2;
80 } );
81 BOOST_TEST_EQ(c, 2);
82 }
83
84 {
85 auto r = f();
86 int what = leaf::try_handle_all(
87 [&r]() -> leaf::result<int>
88 {
89 BOOST_LEAF_CHECK(std::move(r));
90 return 0;
91 },
92 []( info<1> const & x )
93 {

Callers 1

mainFunction · 0.70

Calls 2

try_handle_allFunction · 0.85
fFunction · 0.70

Tested by

no test coverage detected