1[/ 2 / Copyright (c) 2015 Boost.Test contributors 3 / 4 / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 /] 7 8 9[section:debugging Debugging the assertions] 10 11In case you observe a failure in unit tests and you are using a debugger to determine the cause, 12it may get really difficult to step into the expression inside an assertion. Because __BOOST_TEST__ 13builds an expression tree before evaluating it, the "Step Into" function of the debugger will have 14to step into every step of building the expression tree before, you can go into the evaluation of 15the expression. 16 17In order to mitigate the problem, the test module can be build in the mode which disables the 18building of expression trees inside assertions. 19In this mode, the first thing the assertion does is to eagerly evaluate the tested expression. 20You enable this mode by defining symbol __BOOST_TEST_TOOLS_UNDER_DEBUGGER__ (either with `#define` 21or with compiler option `-D`) prior to including any of the __UTF__ headers. 22 23[caution When the eager evaluation of expressions is turned on, the expressions are evaluated 24['literally]: this automatically disables any special semantics, 25 like tolerance for floating-point types or [classref boost::test_tools::per_element] versions 26 of sequence comparisons. This may turn passing assertions into failing assertions and vice-versa. 27 In the case of [classref boost::test_tools::per_element] comparisons of sequences, it may render an 28 ill-formed program, if the sequences of different types are being compared. ] 29 30The inconvenience with __BOOST_TEST_TOOLS_UNDER_DEBUGGER__ is that you have to recompile the test module. 31The __UTF__ gives you another option to compile two versions of the assertions and select the one to be used dynamically 32depending on whether the test module is run under debugger or not. 33This mode is enabled by defining symbol __BOOST_TEST_TOOLS_DEBUGGABLE__ (either with `#define` or with 34compiler option `-D`) prior to the inclusion of any of the __UTF__ headers. 35 36In order to determine if the test module is run under debugger or not, function 37[link boost.debug.under_debugger `boost::debug::under_debugger`] is used. 38 39[caution At present, function [link boost.debug.under_debugger `boost::debug::under_debugger`] 40can correctly detect the debugger only on MSVC and a few Linux variants.] 41 42[endsect] [/ debugging] 43