diff --git a/include/boost/test/tools/interface.hpp b/include/boost/test/tools/interface.hpp index 62f4d785..fe510213 100644 --- a/include/boost/test/tools/interface.hpp +++ b/include/boost/test/tools/interface.hpp @@ -115,21 +115,29 @@ do { \ #ifdef BOOST_TEST_TOOLS_UNDER_DEBUGGER -#define BOOST_TEST_TOOL_UNIV( P, level ) \ +#define BOOST_TEST_TOOL_UNIV( level, P ) \ BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ) \ /**/ +#define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \ + BOOST_TEST_TOOL_UNIV( level, P ) \ +/**/ + #elif defined(BOOST_TEST_TOOLS_DEBUGGABLE) -#define BOOST_TEST_TOOL_UNIV( P, level ) \ +#define BOOST_TEST_TOOL_UNIV( level, P ) \ do { \ - if(::boost::debug::under_debugger() ) \ + if( ::boost::debug::under_debugger() ) \ BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ); \ else \ - BOOST_TEST_TOOL_ET_IMPL( P, level, __VA_ARGS__ ); \ + BOOST_TEST_TOOL_ET_IMPL( P, level ); \ } while( ::boost::test_tools::tt_detail::dummy_cond() ) \ /**/ +#define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \ + BOOST_TEST_TOOL_UNIV( level, P ) \ +/**/ + #else #define BOOST_TEST_TOOL_UNIV( level, P ) \ @@ -182,6 +190,19 @@ do { try { \ }} while( ::boost::test_tools::tt_detail::dummy_cond() ) \ /**/ +#elif defined(BOOST_TEST_TOOLS_DEBUGGABLE) + +#define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\ +do { try { \ + if( ::boost::debug::under_debugger() ) \ + BOOST_TEST_PASSPOINT(); \ + S; \ + BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \ +} catch( E ) { \ + BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \ +}} while( ::boost::test_tools::tt_detail::dummy_cond() ) \ +/**/ + #else #define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\ diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 590a57b6..f0c6f8ce 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -111,7 +111,9 @@ test-suite "writing-test-ts" [ boost.test-self-test run : writing-test-ts : fp-multiprecision-comparison-test ] [ boost.test-self-test run : writing-test-ts : output_test_stream-test ] [ boost.test-self-test run : writing-test-ts : test_tools-test : : baseline-outputs/test_tools-test.pattern ] - [ boost.test-self-test run : writing-test-ts : windows_headers-test ] + [ boost.test-self-test run : writing-test-ts : windows-headers-test ] + [ boost.test-self-test run : writing-test-ts : tools-under-debugger-test ] + [ boost.test-self-test run : writing-test-ts : tools-debuggable-test ] ; #_________________________________________________________________________________________________# diff --git a/test/writing-test-ts/tools-debuggable-test.cpp b/test/writing-test-ts/tools-debuggable-test.cpp new file mode 100644 index 00000000..ec053468 --- /dev/null +++ b/test/writing-test-ts/tools-debuggable-test.cpp @@ -0,0 +1,41 @@ +// (C) Copyright Gennadiy Rozental 2015. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile$ +// +// Version : $Revision$ +// +// Description : testing BOOST_TEST_UNDER_DEBUGGER compilation and operation +// *************************************************************************** + +// Boost.Test +#define BOOST_TEST_TOOLS_DEBUGGABLE +#define BOOST_TEST_MODULE tools under debugger test +#include + +static int +foo( int arg ) +{ + if( arg == 0 ) + throw std::runtime_error("Oops"); + + return arg * arg; +} + +BOOST_AUTO_TEST_CASE( test ) +{ + int i = 2; + BOOST_TEST( foo(i)+1 == 5 ); + + BOOST_TEST( foo(i)+1 == 5, "My message" ); + + BOOST_CHECK_THROW( foo(0), std::runtime_error ); +} + +//____________________________________________________________________________// + +// EOF diff --git a/test/writing-test-ts/tools-under-debugger-test.cpp b/test/writing-test-ts/tools-under-debugger-test.cpp new file mode 100644 index 00000000..c7dad061 --- /dev/null +++ b/test/writing-test-ts/tools-under-debugger-test.cpp @@ -0,0 +1,43 @@ +// (C) Copyright Gennadiy Rozental 2015. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// File : $RCSfile$ +// +// Version : $Revision$ +// +// Description : testing BOOST_TEST_UNDER_DEBUGGER compilation and operation +// *************************************************************************** + +// Boost.Test +#define BOOST_TEST_TOOLS_UNDER_DEBUGGER +#define BOOST_TEST_MODULE tools under debugger test +#include + +#include + +static int +foo( int arg ) +{ + if( arg == 0 ) + throw std::runtime_error("Oops"); + + return arg * arg; +} + +BOOST_AUTO_TEST_CASE( test ) +{ + int i = 2; + BOOST_TEST( foo(i)+1 == 5 ); + + BOOST_TEST( foo(i)+1 == 5, "My message" ); + + BOOST_CHECK_THROW( foo(0), std::runtime_error ); +} + +//____________________________________________________________________________// + +// EOF diff --git a/test/writing-test-ts/windows_headers-test.cpp b/test/writing-test-ts/windows-headers-test.cpp similarity index 100% rename from test/writing-test-ts/windows_headers-test.cpp rename to test/writing-test-ts/windows-headers-test.cpp