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

Function test_exception

test/so_dll_test.cpp:75–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74#ifndef BOOST_LEAF_NO_EXCEPTIONS
75int test_exception(void (*f)(), bool print)
76{
77 int r = leaf::try_catch(
78 [f]
79 {
80 f();
81 return 0;
82 },
83 [&]( my_info<1> x1, my_info<2> x2, leaf::diagnostic_details const & info, leaf::diagnostic_details const & vinfo )
84 {
85 if( x1.value != 1 )
86 return 1;
87 if( x2.value != 2 )
88 return 2;
89 if( BOOST_LEAF_CFG_DIAGNOSTICS && print )
90 {
91#if BOOST_LEAF_CFG_STD_STRING
92 std::ostringstream ss; ss << vinfo;
93 std::string s = ss.str();
94 std::cout << s << std::endl;
95 if( BOOST_LEAF_CFG_DIAGNOSTICS && BOOST_LEAF_CFG_CAPTURE )
96 if( s.find("Test my_info<3>::value = 3") == std::string::npos )
97 return 3;
98#endif
99 }
100 return 0;
101 },
102 [&](leaf::diagnostic_details const & vinfo)
103 {
104#if BOOST_LEAF_CFG_STD_STRING
105 if( print )
106 std::cout << "Test is failing\n" << vinfo;
107#endif
108 return 4;
109 } );
110 return r;
111}
112
113int test_catch(void (*f)())
114{

Callers 2

test_single_threadFunction · 0.85
test_multithreadedFunction · 0.85

Calls 2

try_catchFunction · 0.85
fFunction · 0.70

Tested by

no test coverage detected