123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
- <title>Debugging the assertions</title>
- <link rel="stylesheet" href="../../boostbook.css" type="text/css">
- <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
- <link rel="home" href="../../index.html" title="Boost.Test">
- <link rel="up" href="../testing_tools.html" title="Writing unit tests">
- <link rel="prev" href="internal_details.html" title="BOOST_TEST: details on expressions">
- <link rel="next" href="summary.html" title="Summary of the API for writing tests">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
- <table cellpadding="2" width="100%"><tr>
- <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
- <td align="center"><a href="../../../../../../index.html">Home</a></td>
- <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
- <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
- <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
- <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <a accesskey="p" href="internal_details.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tools.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="summary.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
- </div>
- <div class="section">
- <div class="titlepage"><div><div><h3 class="title">
- <a name="boost_test.testing_tools.debugging"></a><a class="link" href="debugging.html" title="Debugging the assertions">Debugging the assertions</a>
- </h3></div></div></div>
- <p>
- In case you observe a failure in unit tests and you are using a debugger
- to determine the cause, it may get really difficult to step into the expression
- inside an assertion. Because <a class="link" href="../utf_reference/testing_tool_ref/assertion_boost_test_universal_macro.html" title="BOOST_TEST"><code class="computeroutput"><span class="identifier">BOOST_TEST</span></code></a> builds an expression
- tree before evaluating it, the "Step Into" function of the debugger
- will have to step into every step of building the expression tree before,
- you can go into the evaluation of the expression.
- </p>
- <p>
- In order to mitigate the problem, the test module can be build in the mode
- which disables the building of expression trees inside assertions. In this
- mode, the first thing the assertion does is to eagerly evaluate the tested
- expression. You enable this mode by defining symbol <a class="link" href="../utf_reference/testing_tool_ref/assertion_control_under_debugger.html" title="BOOST_TEST_TOOLS_UNDER_DEBUGGER"><code class="computeroutput"><span class="identifier">BOOST_TEST_TOOLS_UNDER_DEBUGGER</span></code></a>
- (either with <code class="computeroutput"><span class="preprocessor">#define</span></code> or
- with compiler option <code class="computeroutput"><span class="special">-</span><span class="identifier">D</span></code>)
- prior to including any of the <span class="emphasis"><em>Unit Test Framework</em></span> headers.
- </p>
- <div class="caution"><table border="0" summary="Caution">
- <tr>
- <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../doc/src/images/caution.png"></td>
- <th align="left">Caution</th>
- </tr>
- <tr><td align="left" valign="top"><p>
- When the eager evaluation of expressions is turned on, the expressions
- are evaluated <span class="emphasis"><em>literally</em></span>: this automatically disables
- any special semantics, like tolerance for floating-point types or <code class="computeroutput"><a class="link" href="../../boost/test_tools/per_element.html" title="Struct per_element">boost::test_tools::per_element</a></code>
- versions of sequence comparisons. This may turn passing assertions into
- failing assertions and vice-versa. In the case of <code class="computeroutput"><a class="link" href="../../boost/test_tools/per_element.html" title="Struct per_element">boost::test_tools::per_element</a></code>
- comparisons of sequences, it may render an ill-formed program, if the sequences
- of different types are being compared.
- </p></td></tr>
- </table></div>
- <p>
- The inconvenience with <a class="link" href="../utf_reference/testing_tool_ref/assertion_control_under_debugger.html" title="BOOST_TEST_TOOLS_UNDER_DEBUGGER"><code class="computeroutput"><span class="identifier">BOOST_TEST_TOOLS_UNDER_DEBUGGER</span></code></a>
- is that you have to recompile the test module. The <span class="emphasis"><em>Unit Test Framework</em></span>
- gives you another option to compile two versions of the assertions and select
- the one to be used dynamically depending on whether the test module is run
- under debugger or not. This mode is enabled by defining symbol <a class="link" href="../utf_reference/testing_tool_ref/assertion_control_under_debuggable.html" title="BOOST_TEST_TOOLS_DEBUGGABLE"><code class="computeroutput"><span class="identifier">BOOST_TEST_TOOLS_DEBUGGABLE</span></code></a> (either
- with <code class="computeroutput"><span class="preprocessor">#define</span></code> or with compiler
- option <code class="computeroutput"><span class="special">-</span><span class="identifier">D</span></code>)
- prior to the inclusion of any of the <span class="emphasis"><em>Unit Test Framework</em></span>
- headers.
- </p>
- <p>
- In order to determine if the test module is run under debugger or not, function
- <a class="link" href="../../boost/debug/under_debugger.html" title="Function under_debugger"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">debug</span><span class="special">::</span><span class="identifier">under_debugger</span></code></a>
- is used.
- </p>
- <div class="caution"><table border="0" summary="Caution">
- <tr>
- <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../doc/src/images/caution.png"></td>
- <th align="left">Caution</th>
- </tr>
- <tr><td align="left" valign="top"><p>
- At present, function <a class="link" href="../../boost/debug/under_debugger.html" title="Function under_debugger"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">debug</span><span class="special">::</span><span class="identifier">under_debugger</span></code></a> can correctly detect
- the debugger only on MSVC and a few Linux variants.
- </p></td></tr>
- </table></div>
- </div>
- <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
- <td align="left"></td>
- <td align="right"><div class="copyright-footer">Copyright © 2001-2019 Boost.Test
- contributors<p>
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
- </p>
- </div></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <a accesskey="p" href="internal_details.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tools.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="summary.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
- </div>
- </body>
- </html>
|