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

Function test

test/capture_result_unload_test.cpp:35–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 2

try_handle_allFunction · 0.85
fFunction · 0.70

Tested by

no test coverage detected