Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Having the same problem, I digged through the documentation (and code) and found a "solution".</p> <p>The Boost UTF uses <code>boost::execution_monitor</code> (in <code>&lt;boost/test/execution_monitor.hpp&gt;</code>). This is designed with the aim to catch everything that could happen during test execution. When an assert is found execution_monitor intercepts it and throws <code>boost::execution_exception</code>. Thus, by using <code>BOOST_REQUIRE_THROW</code> you may assert the failure of an assert.</p> <p>so:</p> <pre><code>#include &lt;boost/test/unit_test.hpp&gt; #include &lt;boost/test/execution_monitor.hpp&gt; // for execution_exception BOOST_AUTO_TEST_CASE(case_1) { BOOST_REQUIRE_THROW(function_w_failing_assert(), boost::execution_exception); } </code></pre> <p>Should do the trick. (It works for me.)</p> <p>However (or disclaimers): </p> <ul> <li><p>It works for me. That is, on Windows XP, MSVC 7.1, boost 1.41.0. It might be unsuitable or broken on your setup.</p></li> <li><p>It might not be the intention of the author of Boost Test. (although it seem to be the purpose of execution_monitor).</p></li> <li><p>It will treat every form of fatal error the same way. I e it could be that something other than your assert is failing. In this case you could miss e g a memory corruption bug, and/or miss a failed failed assert.</p></li> <li><p>It might break on future boost versions.</p></li> <li><p>I expect it would fail if run in Release config, since the assert will be disabled and the code that the assert was set to prevent will run. Resulting in very undefined behavior.</p></li> <li><p>If, in Release config for msvc, some assert-like or other fatal error would occur anyway it would not be caught. (see execution_monitor docs).</p></li> <li><p>If you use assert or not is up to you. I like them.</p></li> </ul> <p>See:</p> <ul> <li><p><a href="http://www.boost.org/doc/libs/1_41_0/libs/test/doc/html/execution-monitor/reference.html#boost.execution_exception" rel="noreferrer">http://www.boost.org/doc/libs/1_41_0/libs/test/doc/html/execution-monitor/reference.html#boost.execution_exception</a></p></li> <li><p>the execution-monitor user-guide.</p></li> </ul> <p>Also, thanks to Gennadiy Rozental (Author of Boost Test), if you happen to read this, Great Work!!</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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