Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the <a href="http://www.boost.org/doc/libs/1_31_0/libs/test/doc/index.html" rel="nofollow noreferrer">Boost Test Library</a>. Look here for a small example:</p> <pre><code>struct my_exception1 { explicit my_exception1( int res_code ) : m_res_code( res_code ) {} int m_res_code; }; struct my_exception2 { explicit my_exception2( int res_code ) : m_res_code( res_code ) {} int m_res_code; }; class dangerous_call { public: dangerous_call( int argc ) : m_argc( argc ) {} int operator()() { if( m_argc &lt; 2 ) throw my_exception1( 23 ); if( m_argc &gt; 3 ) throw my_exception2( 45 ); else if( m_argc &gt; 2 ) throw "too many args"; return 1; } private: int m_argc; }; void translate_my_exception1( my_exception1 const&amp; ex ) { std::cout &lt;&lt; "Caught my_exception1(" &lt;&lt; ex.m_res_code &lt;&lt; ")"&lt;&lt; std::endl; } void translate_my_exception2( my_exception2 const&amp; ex ) { std::cout &lt;&lt; "Caught my_exception2(" &lt;&lt; ex.m_res_code &lt;&lt; ")"&lt;&lt; std::endl; } int cpp_main( int argc , char *[] ) { ::boost::execution_monitor ex_mon; ex_mon.register_exception_translator&lt;my_exception1&gt;( &amp;translate_my_exception1); ex_mon.register_exception_translator&lt;my_exception2&gt;( &amp;translate_my_exception2); try{ // ex_mon.detect_memory_leak( true); ex_mon.execute( ::boost::unit_test::callback0&lt;int&gt;( dangerous_call( argc ) ) ); } catch ( boost::execution_exception const&amp; ex ) { std::cout &lt;&lt; "Caught exception: " &lt;&lt; ex.what() &lt;&lt; std::endl; } return 0; } </code></pre> <p>You have to dig in the documentation. It is a very powerful library to test your software! Anyway with the help of Boost you can catch any kind of exception trigerred anywhere in your function test!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload