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

Function test_result

test/so_dll_test.cpp:36–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34namespace leaf = boost::leaf;
35
36int test_result(leaf::result<void> (*f)(), bool print)
37{
38 int r = leaf::try_handle_all(
39 [f]() -> leaf::result<int>
40 {
41 BOOST_LEAF_CHECK(f());
42 return 0;
43 },
44 [&]( my_info<1> x1, my_info<2> x2, leaf::diagnostic_details const & info, leaf::diagnostic_details const & vinfo )
45 {
46 if( x1.value != 1 )
47 return 1;
48 if( x2.value != 2 )
49 return 2;
50 if( BOOST_LEAF_CFG_DIAGNOSTICS && print )
51 {
52#if BOOST_LEAF_CFG_STD_STRING
53 std::ostringstream ss; ss << vinfo;
54 std::string s = ss.str();
55 std::cout << "Handler matched, diagnostics:\n" << s << std::endl;
56 if( BOOST_LEAF_CFG_DIAGNOSTICS && BOOST_LEAF_CFG_CAPTURE )
57 if( s.find("Test my_info<3>::value = 3") == std::string::npos )
58 return 3;
59#endif
60 }
61 return 0;
62 },
63 [&](leaf::diagnostic_details const & vinfo)
64 {
65#if BOOST_LEAF_CFG_STD_STRING
66 if( print )
67 std::cout << "Test is failing (catch-all), diagnostics:\n" << vinfo << std::endl;
68#endif
69 return 4;
70 } );
71 return r;
72}
73
74#ifndef BOOST_LEAF_NO_EXCEPTIONS
75int test_exception(void (*f)(), bool print)

Callers 2

test_single_threadFunction · 0.70
test_multithreadedFunction · 0.70

Calls 2

try_handle_allFunction · 0.85
fFunction · 0.70

Tested by

no test coverage detected