| 73 | |
| 74 | #ifndef BOOST_LEAF_NO_EXCEPTIONS |
| 75 | int 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 | |
| 113 | int test_catch(void (*f)()) |
| 114 | { |
no test coverage detected