forked from boostorg/assert
Merge branch 'develop'
This commit is contained in:
128
assert.html
128
assert.html
@@ -2,12 +2,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: assert.hpp documentation</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
</head>
|
||||
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%">
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
|
||||
<td width="277"><a href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0" /></a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<h1>assert.hpp</h1>
|
||||
@@ -18,31 +18,32 @@
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<a href="#BOOST_ASSERT">BOOST_ASSERT</a><br>
|
||||
<a href="#BOOST_ASSERT_MSG">BOOST_ASSERT_MSG</a><br>
|
||||
<a href="#BOOST_VERIFY">BOOST_VERIFY</a></p>
|
||||
<a href="#BOOST_ASSERT">BOOST_ASSERT</a><br />
|
||||
<a href="#BOOST_ASSERT_MSG">BOOST_ASSERT_MSG</a><br />
|
||||
<a href="#BOOST_VERIFY">BOOST_VERIFY</a><br />
|
||||
<a href="#BOOST_VERIFY_MSG">BOOST_VERIFY_MSG</a><br />
|
||||
</p>
|
||||
|
||||
<h2><a name="BOOST_ASSERT">BOOST_ASSERT</a></h2>
|
||||
<p>
|
||||
The header <STRONG><boost/assert.hpp></STRONG> defines the macro <b>BOOST_ASSERT</b>,
|
||||
which is similar to the standard <STRONG>assert</STRONG> macro defined in <STRONG><cassert></STRONG>.
|
||||
The header <code><boost/assert.hpp></code> defines the macro <code>BOOST_ASSERT</code>,
|
||||
which is similar to the standard <code>assert</code> macro defined in <code><cassert></code>.
|
||||
The macro is intended to be used in both Boost libraries and user
|
||||
code.
|
||||
</p>
|
||||
<P>By default, <tt>BOOST_ASSERT(expr)</tt> is equivalent to <tt>assert(expr)</tt>.</P>
|
||||
<P>If the macro <STRONG>BOOST_DISABLE_ASSERTS</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||
is included, <tt>BOOST_ASSERT(expr)</tt> is defined as <tt>((void)0)</tt>. This
|
||||
allows users to selectively disable <STRONG>BOOST_ASSERT</STRONG> without
|
||||
affecting the definition of the standard <STRONG>assert</STRONG>.</P>
|
||||
<P>If the macro <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||
is included, <tt>BOOST_ASSERT(expr)</tt> evaluates <b>expr</b> and, if the
|
||||
result is false, evaluates the expression</P>
|
||||
<p>• By default, <code>BOOST_ASSERT(expr)</code> expands to <code>assert(expr)</code>.</p>
|
||||
<p>• If the macro <code>BOOST_DISABLE_ASSERTS</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_ASSERT(expr)</code> expands to <code>((void)0)</code>, regardless of whether
|
||||
the macro <code>NDEBUG</code> is defined. This allows users to selectively disable <code>BOOST_ASSERT</code> without
|
||||
affecting the definition of the standard <code>assert</code>.</p>
|
||||
<p>• If the macro <code>BOOST_ENABLE_ASSERT_HANDLER</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_ASSERT(expr)</code> expands to</p>
|
||||
<blockquote>
|
||||
<P><tt>::boost::assertion_failed(#expr, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>,
|
||||
__FILE__, __LINE__)</tt></P>
|
||||
</blockquote>
|
||||
<P><STRONG>assertion_failed</STRONG> is declared in <STRONG><boost/assert.hpp></STRONG>
|
||||
as</P>
|
||||
<pre>(<a href="../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.boost_helper_macros">BOOST_LIKELY</a>(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>, __FILE__, __LINE__))</pre>
|
||||
</blockquote>
|
||||
<p>That is, it evaluates <code>expr</code> and if it's false, calls <code>::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)</code>.
|
||||
This is true regardless of whether <code>NDEBUG</code> is defined.</p>
|
||||
<p><code>boost::assertion_failed</code> is declared in <code><boost/assert.hpp></code> as</p>
|
||||
<blockquote>
|
||||
<pre>namespace boost
|
||||
{
|
||||
@@ -52,40 +53,28 @@
|
||||
</blockquote>
|
||||
<p>but it is never defined. The user is expected to supply an appropriate
|
||||
definition.</p>
|
||||
<P>As is the case with <STRONG><cassert></STRONG>, <STRONG><boost/assert.hpp></STRONG>
|
||||
can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT</STRONG>
|
||||
will be redefined each time as specified above.</P>
|
||||
<p>• If the macro <code>BOOST_ENABLE_ASSERT_DEBUG_HANDLER</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_ASSERT(expr)</code> expands to <code>((void)0)</code> when <code>NDEBUG</code> is
|
||||
defined. Otherwise the behavior is as if <code>BOOST_ENABLE_ASSERT_HANDLER</code> has been defined.</p>
|
||||
<p>As is the case with <code><cassert></code>, <code><boost/assert.hpp></code>
|
||||
can be included multiple times in a single translation unit. <code>BOOST_ASSERT</code>
|
||||
will be redefined each time as specified above.</p>
|
||||
|
||||
<h2><a name="BOOST_ASSERT_MSG">BOOST_ASSERT_MSG</a></h2>
|
||||
<p>
|
||||
The header <STRONG><boost/assert.hpp></STRONG> defines the macro <b>BOOST_ASSERT_MSG</b>,
|
||||
which is similar to the standard <STRONG>assert</STRONG> macro defined in <STRONG><cassert></STRONG>,
|
||||
but with an additional macro parameter supplying an error message. The macro is intended to be used in both Boost libraries
|
||||
and user code.
|
||||
</p>
|
||||
<P> <tt>BOOST_ASSERT_MSG(expr, msg)</tt> is equivalent to <code>
|
||||
((void)0)</code> if <b>BOOST_DISABLE_ASSERTS</b> or <b>NDEBUG</b> are
|
||||
defined or <code>expr</code> evaluates to <code>true</code>. If those
|
||||
macros and <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> are not
|
||||
defined, and <code>expr</code> evaluates to <code>false</code>, an error
|
||||
message that includes <tt>#expr</tt>, <tt>msg</tt>, <tt> <a href="current_function.html">BOOST_CURRENT_FUNCTION</a></tt>, <tt>
|
||||
__FILE__</tt>, and <tt>__LINE__</tt> is sent to output stream <b>
|
||||
BOOST_ASSERT_MSG_OSTREAM</b>
|
||||
and <code>std::abort()</code> is called.</P>
|
||||
<P> <b>BOOST_ASSERT_MSG_OSTREAM</b> defines the output stream. It defaults to <code>std::cerr</code>.
|
||||
Integrated development environments (IDE's) like Microsoft Visual Studio
|
||||
may produce easier to understand output if messages go to a different
|
||||
stream, such as <code>std::cout</code>. Users may define <b>BOOST_ASSERT_MSG_OSTREAM</b> before including <STRONG><boost/assert.hpp></STRONG>
|
||||
to specify a different output stream. </P>
|
||||
<P>If the macro <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||
is included, instead of sending a error message to an output
|
||||
stream, this expression is evaluated</P>
|
||||
The macro <code>BOOST_ASSERT_MSG</code> is similar to <code>BOOST_ASSERT</code>, but it takes an additional argument,
|
||||
a character literal, supplying an error message.</p>
|
||||
<p>• By default, <code>BOOST_ASSERT_MSG(expr,msg)</code> expands to <code>assert((expr)&&(msg))</code>.</p>
|
||||
<p>• If the macro <code>BOOST_DISABLE_ASSERTS</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_ASSERT_MSG(expr,msg)</code> expands to <code>((void)0)</code>, regardless of whether
|
||||
the macro <code>NDEBUG</code> is defined.</p>
|
||||
<p>• If the macro <code>BOOST_ENABLE_ASSERT_HANDLER</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_ASSERT_MSG(expr,msg)</code> expands to</p>
|
||||
<blockquote>
|
||||
<P><tt>::boost::assertion_failed_msg(#expr, msg, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>,
|
||||
__FILE__, __LINE__)</tt></P>
|
||||
</blockquote>
|
||||
<P><STRONG>assertion_failed_msg</STRONG> is declared in <STRONG><boost/assert.hpp></STRONG>
|
||||
as</P>
|
||||
<pre>(<a href="../config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.boost_helper_macros">BOOST_LIKELY</a>(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>, __FILE__, __LINE__))</pre>
|
||||
</blockquote>
|
||||
<p>This is true regardless of whether <code>NDEBUG</code> is defined.</p>
|
||||
<p><code>boost::assertion_failed_msg</code> is declared in <code><boost/assert.hpp></code> as</p>
|
||||
<blockquote>
|
||||
<pre>namespace boost
|
||||
{
|
||||
@@ -95,21 +84,38 @@
|
||||
</blockquote>
|
||||
<p>but it is never defined. The user is expected to supply an appropriate
|
||||
definition.</p>
|
||||
<P>As is the case with <STRONG><cassert></STRONG>, <STRONG><boost/assert.hpp></STRONG>
|
||||
can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT_MSG</STRONG>
|
||||
will be redefined each time as specified above.</P>
|
||||
<p>• If the macro <code>BOOST_ENABLE_ASSERT_DEBUG_HANDLER</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_ASSERT_MSG(expr)</code> expands to <code>((void)0)</code> when <code>NDEBUG</code> is
|
||||
defined. Otherwise the behavior is as if <code>BOOST_ENABLE_ASSERT_HANDLER</code> has been defined.</p>
|
||||
<p>As is the case with <code><cassert></code>, <code><boost/assert.hpp></code>
|
||||
can be included multiple times in a single translation unit. <code>BOOST_ASSERT_MSG</code>
|
||||
will be redefined each time as specified above.</p>
|
||||
|
||||
<h2><a name="BOOST_VERIFY">BOOST_VERIFY</a></h2>
|
||||
<p><STRONG><boost/assert.hpp></STRONG> also defines the macro <STRONG>BOOST_VERIFY</STRONG>.
|
||||
It has exactly the same behavior as <STRONG>BOOST_ASSERT</STRONG>, except that
|
||||
the expression that is passed to <STRONG>BOOST_VERIFY</STRONG> is always
|
||||
<p>The macro <code>BOOST_VERIFY</code> has the same behavior as <code>BOOST_ASSERT</code>, except that
|
||||
the expression that is passed to <code>BOOST_VERIFY</code> is always
|
||||
evaluated. This is useful when the asserted expression has desirable side
|
||||
effects; it can also help suppress warnings about unused variables when the
|
||||
only use of the variable is inside an assertion.</p>
|
||||
<p><br>
|
||||
<small>Copyright <20> 2002, 2007 by Peter Dimov. Copyright <20> 2011
|
||||
<p>• If the macro <code>BOOST_DISABLE_ASSERTS</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_VERIFY(expr)</code> expands to <code>((void)(expr))</code>.</p>
|
||||
<p>• If the macro <code>BOOST_ENABLE_ASSERT_HANDLER</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_VERIFY(expr)</code> expands to <code>BOOST_ASSERT(expr)</code>.</p>
|
||||
<p>• Otherwise, <code>BOOST_VERIFY(expr)</code> expands to <code>((void)(expr))</code> when <code>NDEBUG</code> is
|
||||
defined, to <code>BOOST_ASSERT(expr)</code> when it's not.</p>
|
||||
<h2><a name="BOOST_VERIFY_MSG">BOOST_VERIFY_MSG</a></h2>
|
||||
<p>The macro <code>BOOST_VERIFY_MSG</code> is similar to <code>BOOST_VERIFY</code>, with an additional parameter, an error message.</p>
|
||||
<p>• If the macro <code>BOOST_DISABLE_ASSERTS</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_VERIFY_MSG(expr,msg)</code> expands to <code>((void)(expr))</code>.</p>
|
||||
<p>• If the macro <code>BOOST_ENABLE_ASSERT_HANDLER</code> is defined when <code><boost/assert.hpp></code>
|
||||
is included, <code>BOOST_VERIFY_MSG(expr,msg)</code> expands to <code>BOOST_ASSERT_MSG(expr,msg)</code>.</p>
|
||||
<p>• Otherwise, <code>BOOST_VERIFY_MSG(expr,msg)</code> expands to <code>((void)(expr))</code> when <code>NDEBUG</code> is
|
||||
defined, to <code>BOOST_ASSERT_MSG(expr,msg)</code> when it's not.</p>
|
||||
<hr />
|
||||
<p>
|
||||
<small>Copyright <20> 2002, 2007, 2014 by Peter Dimov. Copyright <20> 2011
|
||||
by Beman Dawes. Distributed under the Boost Software
|
||||
License, Version 1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||
License, Version 1.0. See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
|
||||
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>.</small></p>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@@ -2,12 +2,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: current_function.hpp documentation</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
</head>
|
||||
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%">
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
<td width="277"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
|
||||
<td width="277"><a href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0" /></a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<h1>current_function.hpp</h1>
|
||||
@@ -18,19 +18,20 @@
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
The header <STRONG><boost/current_function.hpp></STRONG> defines a single
|
||||
macro, <STRONG>BOOST_CURRENT_FUNCTION</STRONG>,<STRONG> </STRONG>similar to the
|
||||
C99 predefined identifier <STRONG>__func__</STRONG>.
|
||||
The header <code><boost/current_function.hpp></code> defines a single
|
||||
macro, <code>BOOST_CURRENT_FUNCTION</code>, similar to the
|
||||
C99 predefined identifier <code>__func__</code>.
|
||||
</p>
|
||||
<P><STRONG>BOOST_CURRENT_FUNCTION</STRONG> expands to a string literal containing
|
||||
<p><code>BOOST_CURRENT_FUNCTION</code> expands to a string literal containing
|
||||
the (fully qualified, if possible) name of the enclosing function. If there is
|
||||
no enclosing function, the behavior is undefined.</P>
|
||||
no enclosing function, the behavior is undefined.</p>
|
||||
<p>Some compilers do not provide a way to obtain the name of the current enclosing
|
||||
function. On such compilers, the string literal has an unspecified value.</p>
|
||||
function. On such compilers, <code>BOOST_CURRENT_FUNCTION</code> expands to
|
||||
<code>"(unknown)"</code>.</p>
|
||||
<hr />
|
||||
<p>
|
||||
<br>
|
||||
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||
1.0. See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||
copy at <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>.</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -2,18 +2,19 @@
|
||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
||||
// BOOST_ASSERT_MSG(expr, msg)
|
||||
// BOOST_VERIFY(expr)
|
||||
// BOOST_VERIFY_MSG(expr, msg)
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2007 Peter Dimov
|
||||
// Copyright (c) 2007, 2014 Peter Dimov
|
||||
// Copyright (c) Beman Dawes 2011
|
||||
//
|
||||
// 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)
|
||||
// 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
|
||||
//
|
||||
// Note: There are no include guards. This is intentional.
|
||||
//
|
||||
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
||||
// See http://www.boost.org/libs/assert/assert.html for documentation.
|
||||
//
|
||||
|
||||
//
|
||||
@@ -22,62 +23,60 @@
|
||||
// boostinspect:naassert_macro
|
||||
//
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// BOOST_ASSERT //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// BOOST_ASSERT
|
||||
//
|
||||
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS)
|
||||
#if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
|
||||
|
||||
# define BOOST_ASSERT(expr) ((void)0)
|
||||
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
void assertion_failed(char const * expr,
|
||||
char const * function, char const * file, long line); // user defined
|
||||
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr)) \
|
||||
? ((void)0) \
|
||||
: ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
#define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
|
||||
# define BOOST_ASSERT(expr) assert(expr)
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// BOOST_ASSERT_MSG //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// BOOST_ASSERT_MSG
|
||||
//
|
||||
|
||||
# undef BOOST_ASSERT_MSG
|
||||
#undef BOOST_ASSERT_MSG
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
|
||||
#if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
|
||||
|
||||
#define BOOST_ASSERT_MSG(expr, msg) ((void)0)
|
||||
# define BOOST_ASSERT_MSG(expr, msg) ((void)0)
|
||||
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
void assertion_failed_msg(char const * expr, char const * msg,
|
||||
char const * function, char const * file, long line); // user defined
|
||||
} // namespace boost
|
||||
namespace boost
|
||||
{
|
||||
void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line); // user defined
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \
|
||||
? ((void)0) \
|
||||
: ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
#define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
# include <assert.h>
|
||||
# define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
|
||||
|
||||
/*
|
||||
#ifndef BOOST_ASSERT_HPP
|
||||
#define BOOST_ASSERT_HPP
|
||||
#include <cstdlib>
|
||||
@@ -122,11 +121,12 @@ namespace boost
|
||||
? ((void)0) \
|
||||
: ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \
|
||||
BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
*/
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// BOOST_VERIFY //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
//
|
||||
// BOOST_VERIFY
|
||||
//
|
||||
|
||||
#undef BOOST_VERIFY
|
||||
|
||||
@@ -139,3 +139,19 @@ namespace boost
|
||||
# define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// BOOST_VERIFY_MSG
|
||||
//
|
||||
|
||||
#undef BOOST_VERIFY_MSG
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
|
||||
|
||||
# define BOOST_VERIFY_MSG(expr, msg) ((void)(expr))
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_VERIFY_MSG(expr, msg) BOOST_ASSERT_MSG(expr,msg)
|
||||
|
||||
#endif
|
||||
|
@@ -12,11 +12,11 @@
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// 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)
|
||||
// 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
|
||||
//
|
||||
// http://www.boost.org/libs/utility/current_function.html
|
||||
// http://www.boost.org/libs/assert/current_function.html
|
||||
//
|
||||
|
||||
namespace boost
|
||||
@@ -52,6 +52,10 @@ inline void current_function_helper()
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __func__
|
||||
|
||||
#elif defined(__cplusplus) && (__cplusplus >= 201103)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __func__
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION "(unknown)"
|
||||
@@ -65,4 +69,3 @@ inline void current_function_helper()
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
||||
|
||||
|
@@ -14,4 +14,9 @@ test-suite "assert"
|
||||
[ run assert_test.cpp ]
|
||||
[ run current_function_test.cpp : : : <test-info>always_show_run_output ]
|
||||
[ run verify_test.cpp ]
|
||||
# expansion tests are in exp/ so that there is a backslash in the path on Windows
|
||||
[ run exp/assert_exp_test.cpp ]
|
||||
[ run exp/assert_msg_exp_test.cpp ]
|
||||
[ run exp/verify_exp_test.cpp ]
|
||||
[ run exp/verify_msg_exp_test.cpp ]
|
||||
;
|
||||
|
164
test/exp/assert_exp_test.cpp
Normal file
164
test/exp/assert_exp_test.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
//
|
||||
// assert_exp_test.cpp - tests BOOST_ASSERT expansion
|
||||
//
|
||||
// Copyright (c) 2014 Peter Dimov
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
// Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled
|
||||
static std::string quote( std::string const & s )
|
||||
{
|
||||
std::string r;
|
||||
r.reserve( s.size() );
|
||||
|
||||
for( char const * p = s.c_str(); *p; ++p )
|
||||
{
|
||||
r += *p;
|
||||
if( *p == '\\' ) r += *p;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// default case, !NDEBUG
|
||||
// BOOST_ASSERT(x) -> assert(x)
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef assert
|
||||
|
||||
void test_default()
|
||||
{
|
||||
std::string v1 = BOOST_STRINGIZE(BOOST_ASSERT(x1));
|
||||
BOOST_TEST_EQ( v1, "assert(x1)" );
|
||||
}
|
||||
|
||||
// default case, NDEBUG
|
||||
// BOOST_ASSERT(x) -> assert(x)
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef assert
|
||||
|
||||
void test_default_ndebug()
|
||||
{
|
||||
std::string v2 = BOOST_STRINGIZE(BOOST_ASSERT(x2));
|
||||
BOOST_TEST_EQ( v2, "assert(x2)" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, !NDEBUG
|
||||
// BOOST_ASSERT(x) -> ((void)0)
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
std::string v3 = BOOST_STRINGIZE(BOOST_ASSERT(x3));
|
||||
BOOST_TEST_EQ( v3, "((void)0)" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, NDEBUG
|
||||
// BOOST_ASSERT(x) -> ((void)0)
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled_ndebug()
|
||||
{
|
||||
std::string v4 = BOOST_STRINGIZE(BOOST_ASSERT(x4));
|
||||
BOOST_TEST_EQ( v4, "((void)0)" );
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
|
||||
// BOOST_ASSERT(expr) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#undef BOOST_LIKELY
|
||||
#undef BOOST_CURRENT_FUNCTION
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT(x5)); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed(\"x5\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
|
||||
BOOST_TEST_EQ( v5, w5 );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
|
||||
// BOOST_ASSERT(expr) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_handler_ndebug()
|
||||
{
|
||||
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT(x6)); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed(\"x6\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
|
||||
BOOST_TEST_EQ( v6, w6 );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
|
||||
// same as BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_debug_handler()
|
||||
{
|
||||
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT(x7)); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed(\"x7\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
|
||||
BOOST_TEST_EQ( v7, w7 );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
|
||||
// BOOST_ASSERT(x) -> ((void)0)
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_debug_handler_ndebug()
|
||||
{
|
||||
std::string v8 = BOOST_STRINGIZE(BOOST_ASSERT(x8));
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler_ndebug()";
|
||||
BOOST_TEST_EQ( v8, "((void)0)" );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_default_ndebug();
|
||||
test_disabled();
|
||||
test_disabled_ndebug();
|
||||
test_handler();
|
||||
test_handler_ndebug();
|
||||
test_debug_handler();
|
||||
test_debug_handler_ndebug();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
164
test/exp/assert_msg_exp_test.cpp
Normal file
164
test/exp/assert_msg_exp_test.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
//
|
||||
// assert_msg_exp_test.cpp - tests BOOST_ASSERT_MSG expansion
|
||||
//
|
||||
// Copyright (c) 2014 Peter Dimov
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
// Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled
|
||||
static std::string quote( std::string const & s )
|
||||
{
|
||||
std::string r;
|
||||
r.reserve( s.size() );
|
||||
|
||||
for( char const * p = s.c_str(); *p; ++p )
|
||||
{
|
||||
r += *p;
|
||||
if( *p == '\\' ) r += *p;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// default case, !NDEBUG
|
||||
// BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m"))
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef assert
|
||||
|
||||
void test_default()
|
||||
{
|
||||
std::string v1 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x1, "m1"));
|
||||
BOOST_TEST_EQ( v1, "assert((x1)&&(\"m1\"))" );
|
||||
}
|
||||
|
||||
// default case, NDEBUG
|
||||
// BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m"))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef assert
|
||||
|
||||
void test_default_ndebug()
|
||||
{
|
||||
std::string v2 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x2, "m2"));
|
||||
BOOST_TEST_EQ( v2, "assert((x2)&&(\"m2\"))" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, !NDEBUG
|
||||
// BOOST_ASSERT_MSG(x,"m") -> ((void)0)
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
std::string v3 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x3, "m3"));
|
||||
BOOST_TEST_EQ( v3, "((void)0)" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, NDEBUG
|
||||
// BOOST_ASSERT_MSG(x,"m") -> ((void)0)
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled_ndebug()
|
||||
{
|
||||
std::string v4 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x4, "m4"));
|
||||
BOOST_TEST_EQ( v4, "((void)0)" );
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
|
||||
// BOOST_ASSERT_MSG(expr, msg) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#undef BOOST_LIKELY
|
||||
#undef BOOST_CURRENT_FUNCTION
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x5, "m5")); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed_msg(\"x5\", \"m5\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
|
||||
BOOST_TEST_EQ( v5, w5 );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
|
||||
// BOOST_ASSERT_MSG(expr, msg) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_handler_ndebug()
|
||||
{
|
||||
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x6, "m6")); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed_msg(\"x6\", \"m6\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
|
||||
BOOST_TEST_EQ( v6, w6 );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
|
||||
// same as BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_debug_handler()
|
||||
{
|
||||
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x7, "m7")); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed_msg(\"x7\", \"m7\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
|
||||
BOOST_TEST_EQ( v7, w7 );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
|
||||
// BOOST_ASSERT_MSG(x,"m") -> ((void)0)
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_debug_handler_ndebug()
|
||||
{
|
||||
std::string v8 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x8, "m8"));
|
||||
|
||||
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler_ndebug()";
|
||||
BOOST_TEST_EQ( v8, "((void)0)" );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_default_ndebug();
|
||||
test_disabled();
|
||||
test_disabled_ndebug();
|
||||
test_handler();
|
||||
test_handler_ndebug();
|
||||
test_debug_handler();
|
||||
test_debug_handler_ndebug();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
136
test/exp/verify_exp_test.cpp
Normal file
136
test/exp/verify_exp_test.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// verify_exp_test.cpp - tests BOOST_ASSERT expansion
|
||||
//
|
||||
// Copyright (c) 2014 Peter Dimov
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
// default case, !NDEBUG
|
||||
// BOOST_VERIFY(x) -> BOOST_ASSERT(x)
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
void test_default()
|
||||
{
|
||||
std::string v1 = BOOST_STRINGIZE(BOOST_VERIFY(x1));
|
||||
BOOST_TEST_EQ( v1, "BOOST_ASSERT(x1)" );
|
||||
}
|
||||
|
||||
// default case, NDEBUG
|
||||
// BOOST_VERIFY(x) -> ((void)(x))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_default_ndebug()
|
||||
{
|
||||
std::string v2 = BOOST_STRINGIZE(BOOST_VERIFY(x2));
|
||||
BOOST_TEST_EQ( v2, "((void)(x2))" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, !NDEBUG
|
||||
// BOOST_VERIFY(x) -> ((void)(x))
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
std::string v3 = BOOST_STRINGIZE(BOOST_VERIFY(x3));
|
||||
BOOST_TEST_EQ( v3, "((void)(x3))" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, NDEBUG
|
||||
// BOOST_VERIFY(x) -> ((void)(x))
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled_ndebug()
|
||||
{
|
||||
std::string v4 = BOOST_STRINGIZE(BOOST_VERIFY(x4));
|
||||
BOOST_TEST_EQ( v4, "((void)(x4))" );
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
|
||||
// BOOST_VERIFY(x) -> BOOST_ASSERT(x)
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
std::string v5 = BOOST_STRINGIZE(BOOST_VERIFY(x5));
|
||||
BOOST_TEST_EQ( v5, "BOOST_ASSERT(x5)" );
|
||||
}
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
void test_handler_ndebug()
|
||||
{
|
||||
std::string v6 = BOOST_STRINGIZE(BOOST_VERIFY(x6));
|
||||
BOOST_TEST_EQ( v6, "BOOST_ASSERT(x6)" );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
|
||||
// BOOST_VERIFY(x) -> BOOST_ASSERT(x)
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
void test_debug_handler()
|
||||
{
|
||||
std::string v7 = BOOST_STRINGIZE(BOOST_VERIFY(x7));
|
||||
BOOST_TEST_EQ( v7, "BOOST_ASSERT(x7)" );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
|
||||
// BOOST_VERIFY(x) -> ((void)(x))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_debug_handler_ndebug()
|
||||
{
|
||||
std::string v8 = BOOST_STRINGIZE(BOOST_VERIFY(x8));
|
||||
BOOST_TEST_EQ( v8, "((void)(x8))" );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_default_ndebug();
|
||||
test_disabled();
|
||||
test_disabled_ndebug();
|
||||
test_handler();
|
||||
test_handler_ndebug();
|
||||
test_debug_handler();
|
||||
test_debug_handler_ndebug();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
140
test/exp/verify_msg_exp_test.cpp
Normal file
140
test/exp/verify_msg_exp_test.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// verify_msg_exp_test.cpp - tests BOOST_VERIFY_MSG expansion
|
||||
//
|
||||
// Copyright (c) 2014 Peter Dimov
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
// default case, !NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,"m") -> BOOST_ASSERT_MSG(x,"m")
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT_MSG
|
||||
|
||||
void test_default()
|
||||
{
|
||||
std::string v1 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x1, m1));
|
||||
BOOST_TEST_EQ( v1, "BOOST_ASSERT_MSG(x1,m1)" );
|
||||
}
|
||||
|
||||
// default case, NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_default_ndebug()
|
||||
{
|
||||
std::string v2 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x2, m2));
|
||||
BOOST_TEST_EQ( v2, "((void)(x2))" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, !NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
std::string v3 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x3, "m3"));
|
||||
BOOST_TEST_EQ( v3, "((void)(x3))" );
|
||||
}
|
||||
|
||||
// BOOST_DISABLE_ASSERTS, NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled_ndebug()
|
||||
{
|
||||
std::string v4 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x4, "m4"));
|
||||
BOOST_TEST_EQ( v4, "((void)(x4))" );
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,m) -> BOOST_ASSERT_MSG(x,m)
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT_MSG
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
std::string v5 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x5, m5));
|
||||
BOOST_TEST_EQ( v5, "BOOST_ASSERT_MSG(x5,m5)" );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,n) -> BOOST_ASSERT_MSG(x,m)
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT_MSG
|
||||
|
||||
void test_handler_ndebug()
|
||||
{
|
||||
std::string v6 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x6, m6));
|
||||
BOOST_TEST_EQ( v6, "BOOST_ASSERT_MSG(x6,m6)" );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,n) -> BOOST_ASSERT_MSG(x,m)
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
#undef NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#undef BOOST_ASSERT_MSG
|
||||
|
||||
void test_debug_handler()
|
||||
{
|
||||
std::string v7 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x7, m7));
|
||||
BOOST_TEST_EQ( v7, "BOOST_ASSERT_MSG(x7,m7)" );
|
||||
}
|
||||
|
||||
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
|
||||
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
|
||||
|
||||
#define NDEBUG
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_debug_handler_ndebug()
|
||||
{
|
||||
std::string v8 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x8, "m8"));
|
||||
BOOST_TEST_EQ( v8, "((void)(x8))" );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_default_ndebug();
|
||||
test_disabled();
|
||||
test_disabled_ndebug();
|
||||
test_handler();
|
||||
test_handler_ndebug();
|
||||
test_debug_handler();
|
||||
test_debug_handler_ndebug();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user