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

Function test

test/capture_exception_unload_test.cpp:36–121  ·  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_catch(
42 [&r]
43 {
44 (void) r.value();
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_catch(
64 [&r]
65 {
66 (void) r.value();
67 },
68 [&c]( info<2> const & x )
69 {
70 BOOST_TEST_EQ(x.value, 2);
71 BOOST_TEST_EQ(c, 0);
72 c = 1;
73 },
74 [&c]
75 {
76 BOOST_TEST_EQ(c, 0);
77 c = 2;
78 } );
79 BOOST_TEST_EQ(c, 2);
80 }
81
82 {
83 auto r = f();
84 int what = leaf::try_catch(
85 [&r]
86 {
87 (void) r.value();
88 return 0;
89 },
90 []( info<1> const & x )
91 {
92 BOOST_TEST_EQ(x.value, 1);
93 return 1;

Callers 1

mainFunction · 0.70

Calls 3

try_catchFunction · 0.85
fFunction · 0.70
valueMethod · 0.45

Tested by

no test coverage detected