mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 02:44:10 +00:00
Remove assert from utility
This commit is contained in:
parent
9c4d2843da
commit
d4b5fde5a8
115
assert.html
115
assert.html
@ -1,115 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: assert.hpp documentation</title>
|
||||
<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>
|
||||
<td align="center">
|
||||
<h1>assert.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</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>
|
||||
|
||||
<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 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>
|
||||
<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>
|
||||
<blockquote>
|
||||
<pre>namespace boost
|
||||
{
|
||||
void assertion_failed(char const * expr, char const * function, char const * file, long line);
|
||||
}
|
||||
</pre>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<blockquote>
|
||||
<pre>namespace boost
|
||||
{
|
||||
void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line);
|
||||
}
|
||||
</pre>
|
||||
</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>
|
||||
|
||||
<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
|
||||
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 © 2002, 2007 by Peter Dimov. Copyright © 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>
|
||||
</body>
|
||||
</html>
|
153
assert_test.cpp
153
assert_test.cpp
@ -1,153 +0,0 @@
|
||||
//
|
||||
// assert_test.cpp - a test for boost/assert.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (2) 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)
|
||||
//
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_default()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_ASSERT(1);
|
||||
BOOST_ASSERT(x);
|
||||
BOOST_ASSERT(x == 1);
|
||||
BOOST_ASSERT(&x);
|
||||
|
||||
BOOST_ASSERT_MSG(1, "msg");
|
||||
BOOST_ASSERT_MSG(x, "msg");
|
||||
BOOST_ASSERT_MSG(x == 1, "msg");
|
||||
BOOST_ASSERT_MSG(&x, "msg");
|
||||
}
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_ASSERT(1);
|
||||
BOOST_ASSERT(x);
|
||||
BOOST_ASSERT(x == 1);
|
||||
BOOST_ASSERT(&x);
|
||||
|
||||
BOOST_ASSERT_MSG(1, "msg");
|
||||
BOOST_ASSERT_MSG(x, "msg");
|
||||
BOOST_ASSERT_MSG(x == 1, "msg");
|
||||
BOOST_ASSERT_MSG(&x, "msg");
|
||||
|
||||
BOOST_ASSERT(0);
|
||||
BOOST_ASSERT(!x);
|
||||
BOOST_ASSERT(x == 0);
|
||||
|
||||
BOOST_ASSERT_MSG(0, "msg");
|
||||
BOOST_ASSERT_MSG(!x, "msg");
|
||||
BOOST_ASSERT_MSG(x == 0, "msg");
|
||||
|
||||
void * p = 0;
|
||||
|
||||
BOOST_ASSERT(p);
|
||||
BOOST_ASSERT_MSG(p, "msg");
|
||||
|
||||
// supress warnings
|
||||
p = &x;
|
||||
p = &p;
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
int handler_invoked = 0;
|
||||
int msg_handler_invoked = 0;
|
||||
|
||||
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
|
||||
{
|
||||
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using std::printf;
|
||||
#endif
|
||||
|
||||
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
|
||||
++handler_invoked;
|
||||
}
|
||||
|
||||
void boost::assertion_failed_msg(char const * expr, char const * msg, char const * function,
|
||||
char const * file, long line)
|
||||
{
|
||||
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using std::printf;
|
||||
#endif
|
||||
|
||||
printf("Expression: %s Message: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n",
|
||||
expr, msg, function, file, line);
|
||||
++msg_handler_invoked;
|
||||
}
|
||||
|
||||
struct X
|
||||
{
|
||||
static void f()
|
||||
{
|
||||
BOOST_ASSERT(0);
|
||||
BOOST_ASSERT_MSG(0, "msg f()");
|
||||
}
|
||||
};
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_ASSERT(1);
|
||||
BOOST_ASSERT(x);
|
||||
BOOST_ASSERT(x == 1);
|
||||
BOOST_ASSERT(&x);
|
||||
|
||||
BOOST_ASSERT_MSG(1, "msg2");
|
||||
BOOST_ASSERT_MSG(x, "msg3");
|
||||
BOOST_ASSERT_MSG(x == 1, "msg4");
|
||||
BOOST_ASSERT_MSG(&x, "msg5");
|
||||
|
||||
BOOST_ASSERT(0);
|
||||
BOOST_ASSERT(!x);
|
||||
BOOST_ASSERT(x == 0);
|
||||
|
||||
BOOST_ASSERT_MSG(0,"msg 0");
|
||||
BOOST_ASSERT_MSG(!x, "msg !x");
|
||||
BOOST_ASSERT_MSG(x == 0, "msg x == 0");
|
||||
|
||||
void * p = 0;
|
||||
|
||||
BOOST_ASSERT(p);
|
||||
BOOST_ASSERT_MSG(p, "msg p");
|
||||
|
||||
X::f();
|
||||
|
||||
BOOST_ASSERT(handler_invoked == 5);
|
||||
BOOST_TEST(handler_invoked == 5);
|
||||
|
||||
BOOST_ASSERT_MSG(msg_handler_invoked == 5, "msg_handler_invoked count is wrong");
|
||||
BOOST_TEST(msg_handler_invoked == 5);
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
#undef BOOST_ENABLE_ASSERT_MSG_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_disabled();
|
||||
test_handler();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Boost: current_function.hpp documentation</title>
|
||||
<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>
|
||||
<td align="center">
|
||||
<h1>current_function.hpp</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="64"> </td>
|
||||
</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>.
|
||||
</p>
|
||||
<P><STRONG>BOOST_CURRENT_FUNCTION</STRONG> 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>
|
||||
<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>
|
||||
<p>
|
||||
<br>
|
||||
<small>Copyright © 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>
|
||||
</body>
|
||||
</html>
|
@ -1,40 +0,0 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(disable: 4786) // identifier truncated in debug info
|
||||
#pragma warning(disable: 4710) // function not inlined
|
||||
#pragma warning(disable: 4711) // function selected for automatic inline expansion
|
||||
#pragma warning(disable: 4514) // unreferenced inline removed
|
||||
#endif
|
||||
|
||||
//
|
||||
// current_function_test.cpp - a test for boost/current_function.hpp
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
void message(char const * file, long line, char const * func, char const * msg)
|
||||
{
|
||||
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using std::printf;
|
||||
#endif
|
||||
|
||||
printf("%s(%ld): %s in function '%s'\n", file, line, msg, func);
|
||||
}
|
||||
|
||||
#define MESSAGE(msg) message(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, msg)
|
||||
|
||||
int main()
|
||||
{
|
||||
MESSAGE("assertion failed");
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
//
|
||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
||||
// BOOST_ASSERT_MSG(expr, msg)
|
||||
// BOOST_VERIFY(expr)
|
||||
//
|
||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2007 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)
|
||||
//
|
||||
// Note: There are no include guards. This is intentional.
|
||||
//
|
||||
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
||||
//
|
||||
|
||||
//
|
||||
// Stop inspect complaining about use of 'assert':
|
||||
//
|
||||
// boostinspect:naassert_macro
|
||||
//
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// BOOST_ASSERT //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#undef BOOST_ASSERT
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS)
|
||||
|
||||
# define BOOST_ASSERT(expr) ((void)0)
|
||||
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||
|
||||
#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
|
||||
} // namespace boost
|
||||
|
||||
#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 //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
# undef BOOST_ASSERT_MSG
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
|
||||
|
||||
#define BOOST_ASSERT_MSG(expr, msg) ((void)0)
|
||||
|
||||
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||
|
||||
#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
|
||||
|
||||
#define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \
|
||||
? ((void)0) \
|
||||
: ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
#ifndef BOOST_ASSERT_HPP
|
||||
#define BOOST_ASSERT_HPP
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
|
||||
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||
// some other stream, so allow user to configure output stream:
|
||||
#ifndef BOOST_ASSERT_MSG_OSTREAM
|
||||
# define BOOST_ASSERT_MSG_OSTREAM std::cerr
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace assertion
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
// Note: The template is needed to make the function non-inline and avoid linking errors
|
||||
template< typename CharT >
|
||||
BOOST_NOINLINE void assertion_failed_msg(CharT const * expr, char const * msg, char const * function,
|
||||
char const * file, long line)
|
||||
{
|
||||
BOOST_ASSERT_MSG_OSTREAM
|
||||
<< "***** Internal Program Error - assertion (" << expr << ") failed in "
|
||||
<< function << ":\n"
|
||||
<< file << '(' << line << "): " << msg << std::endl;
|
||||
#ifdef UNDER_CE
|
||||
// The Windows CE CRT library does not have abort() so use exit(-1) instead.
|
||||
std::exit(-1);
|
||||
#else
|
||||
std::abort();
|
||||
#endif
|
||||
}
|
||||
} // detail
|
||||
} // assertion
|
||||
} // detail
|
||||
#endif
|
||||
|
||||
#define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \
|
||||
? ((void)0) \
|
||||
: ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \
|
||||
BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
// BOOST_VERIFY //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#undef BOOST_VERIFY
|
||||
|
||||
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
|
||||
|
||||
# define BOOST_VERIFY(expr) ((void)(expr))
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
|
||||
|
||||
#endif
|
@ -1,68 +0,0 @@
|
||||
#ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
||||
#define BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/current_function.hpp - BOOST_CURRENT_FUNCTION
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// http://www.boost.org/libs/utility/current_function.html
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void current_function_helper()
|
||||
{
|
||||
|
||||
#if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#elif defined(__DMC__) && (__DMC__ >= 0x810)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||
|
||||
#elif defined(__FUNCSIG__)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
|
||||
|
||||
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNCTION__
|
||||
|
||||
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __FUNC__
|
||||
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION __func__
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_CURRENT_FUNCTION "(unknown)"
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
|
||||
|
@ -15,13 +15,11 @@
|
||||
<blockquote>
|
||||
<p>
|
||||
<a href="utility.htm#addressof">addressof</a><br>
|
||||
<a href="assert.html">assert</a><br>
|
||||
<a href="base_from_member.html">base_from_member</a><br>
|
||||
<a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a><br>
|
||||
<a href="call_traits.htm">call_traits</a><br>
|
||||
<a href="checked_delete.html">checked_delete</a><br>
|
||||
<a href="compressed_pair.htm">compressed_pair</a><br>
|
||||
<a href="current_function.html">current_function</a><br>
|
||||
<a href="doc/html/declval.html">declval</a><br>
|
||||
<a href="enable_if.html">enable_if</a><br>
|
||||
<a href="in_place_factories.html">in_place_factory</a><br>
|
||||
|
@ -20,14 +20,12 @@ test-suite utility
|
||||
[ run ../addressof_np_test.cpp ]
|
||||
[ run ../addressof_test.cpp ]
|
||||
[ run ../addressof_test2.cpp ]
|
||||
[ run ../assert_test.cpp ]
|
||||
[ run ../base_from_member_test.cpp ]
|
||||
[ run ../binary_search_test.cpp ]
|
||||
[ run ../binary_test.cpp ]
|
||||
[ run ../call_traits_test.cpp : -u ]
|
||||
[ compile-fail ../checked_delete_test.cpp ]
|
||||
[ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/<link>static : -u ]
|
||||
[ run ../current_function_test.cpp : : : <test-info>always_show_run_output ]
|
||||
[ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ compile-fail ../noncopyable_test.cpp ]
|
||||
@ -48,7 +46,6 @@ test-suite utility
|
||||
[ compile-fail ../value_init_test_fail3.cpp ]
|
||||
[ compile-fail ../initialized_test_fail1.cpp ]
|
||||
[ compile-fail ../initialized_test_fail2.cpp ]
|
||||
[ run ../verify_test.cpp ]
|
||||
[ run explicit_operator_bool.cpp ]
|
||||
[ compile-fail explicit_operator_bool_compile_fail_conv_int.cpp ]
|
||||
[ compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ]
|
||||
|
126
verify_test.cpp
126
verify_test.cpp
@ -1,126 +0,0 @@
|
||||
//
|
||||
// verify_test.cpp - a test for BOOST_VERIFY
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2007 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/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
int f( int & x )
|
||||
{
|
||||
return ++x;
|
||||
}
|
||||
|
||||
void test_default()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_VERIFY( 1 );
|
||||
BOOST_VERIFY( x == 1 );
|
||||
BOOST_VERIFY( ++x );
|
||||
BOOST_VERIFY( f(x) );
|
||||
BOOST_VERIFY( &x );
|
||||
|
||||
BOOST_TEST( x == 3 );
|
||||
}
|
||||
|
||||
#define BOOST_DISABLE_ASSERTS
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
void test_disabled()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_VERIFY( 1 );
|
||||
BOOST_VERIFY( x == 1 );
|
||||
BOOST_VERIFY( ++x );
|
||||
BOOST_VERIFY( f(x) );
|
||||
BOOST_VERIFY( &x );
|
||||
|
||||
BOOST_TEST( x == 3 );
|
||||
|
||||
BOOST_VERIFY( 0 );
|
||||
BOOST_VERIFY( !x );
|
||||
BOOST_VERIFY( x == 0 );
|
||||
BOOST_VERIFY( !++x );
|
||||
BOOST_VERIFY( !f(x) );
|
||||
|
||||
BOOST_TEST( x == 5 );
|
||||
|
||||
void * p = 0;
|
||||
BOOST_VERIFY( p );
|
||||
}
|
||||
|
||||
#undef BOOST_DISABLE_ASSERTS
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
int handler_invoked = 0;
|
||||
|
||||
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
|
||||
{
|
||||
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using std::printf;
|
||||
#endif
|
||||
|
||||
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
|
||||
++handler_invoked;
|
||||
}
|
||||
|
||||
struct X
|
||||
{
|
||||
static bool f()
|
||||
{
|
||||
BOOST_VERIFY( 0 );
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void test_handler()
|
||||
{
|
||||
int x = 1;
|
||||
|
||||
BOOST_VERIFY( 1 );
|
||||
BOOST_VERIFY( x == 1 );
|
||||
BOOST_VERIFY( ++x );
|
||||
BOOST_VERIFY( f(x) );
|
||||
BOOST_VERIFY( &x );
|
||||
|
||||
BOOST_TEST( x == 3 );
|
||||
|
||||
BOOST_VERIFY( 0 );
|
||||
BOOST_VERIFY( !x );
|
||||
BOOST_VERIFY( x == 0 );
|
||||
BOOST_VERIFY( !++x );
|
||||
BOOST_VERIFY( !f(x) );
|
||||
|
||||
BOOST_TEST( x == 5 );
|
||||
|
||||
void * p = 0;
|
||||
BOOST_VERIFY( p );
|
||||
|
||||
BOOST_VERIFY( X::f() );
|
||||
|
||||
BOOST_TEST( handler_invoked == 8 );
|
||||
}
|
||||
|
||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
int main()
|
||||
{
|
||||
test_default();
|
||||
test_disabled();
|
||||
test_handler();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user