From d4b5fde5a86186c9ed5fba312443c6b6994b4bd7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 9 Feb 2014 17:56:48 +0200 Subject: [PATCH] Remove assert from utility --- assert.html | 115 ---------------------- assert_test.cpp | 153 ----------------------------- current_function.html | 36 ------- current_function_test.cpp | 40 -------- include/boost/assert.hpp | 141 -------------------------- include/boost/current_function.hpp | 68 ------------- index.html | 2 - test/Jamfile.v2 | 3 - verify_test.cpp | 126 ------------------------ 9 files changed, 684 deletions(-) delete mode 100644 assert.html delete mode 100644 assert_test.cpp delete mode 100644 current_function.html delete mode 100644 current_function_test.cpp delete mode 100644 include/boost/assert.hpp delete mode 100644 include/boost/current_function.hpp delete mode 100644 verify_test.cpp diff --git a/assert.html b/assert.html deleted file mode 100644 index 5f3f6e7..0000000 --- a/assert.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - Boost: assert.hpp documentation - - - - - - - - - - - -
boost.png (6897 bytes) - -

assert.hpp

-
 
-

- BOOST_ASSERT
- BOOST_ASSERT_MSG
- BOOST_VERIFY

- -

BOOST_ASSERT

-

- The header <boost/assert.hpp> defines the macro BOOST_ASSERT, - which is similar to the standard assert macro defined in <cassert>. - The macro is intended to be used in both Boost libraries and user - code. -

-

By default, BOOST_ASSERT(expr) is equivalent to assert(expr).

-

If the macro BOOST_DISABLE_ASSERTS is defined when <boost/assert.hpp> - is included, BOOST_ASSERT(expr) is defined as ((void)0). This - allows users to selectively disable BOOST_ASSERT without - affecting the definition of the standard assert.

-

If the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> - is included, BOOST_ASSERT(expr) evaluates expr and, if the - result is false, evaluates the expression

-
-

::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, - __FILE__, __LINE__)

-
-

assertion_failed is declared in <boost/assert.hpp> - as

-
-
namespace boost
-{
-  void assertion_failed(char const * expr, char const * function, char const * file, long line);
-}
-
-
-

but it is never defined. The user is expected to supply an appropriate - definition.

-

As is the case with <cassert>, <boost/assert.hpp> - can be included multiple times in a single translation unit. BOOST_ASSERT - will be redefined each time as specified above.

- -

BOOST_ASSERT_MSG

-

- The header <boost/assert.hpp> defines the macro BOOST_ASSERT_MSG, - which is similar to the standard assert macro defined in <cassert>, - but with an additional macro parameter supplying an error message. The macro is intended to be used in both Boost libraries - and user code. -

-

BOOST_ASSERT_MSG(expr, msg) is equivalent to - ((void)0) if BOOST_DISABLE_ASSERTS or NDEBUG are - defined or expr evaluates to true. If those - macros and BOOST_ENABLE_ASSERT_HANDLER are not - defined, and expr evaluates to false, an error - message that includes #expr, msg, BOOST_CURRENT_FUNCTION, - __FILE__, and __LINE__ is sent to output stream - BOOST_ASSERT_MSG_OSTREAM - and std::abort() is called.

-

BOOST_ASSERT_MSG_OSTREAM defines the output stream. It defaults to std::cerr. - Integrated development environments (IDE's) like Microsoft Visual Studio - may produce easier to understand output if messages go to a different - stream, such as std::cout. Users may define BOOST_ASSERT_MSG_OSTREAM before including <boost/assert.hpp> - to specify a different output stream. 

-

If the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> - is included, instead of sending a error message to an output - stream, this expression is evaluated

-
-

::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, - __FILE__, __LINE__)

-
-

assertion_failed_msg is declared in <boost/assert.hpp> - as

-
-
namespace boost
-{
-  void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line);
-}
-
-
-

but it is never defined. The user is expected to supply an appropriate - definition.

-

As is the case with <cassert>, <boost/assert.hpp> - can be included multiple times in a single translation unit. BOOST_ASSERT_MSG - will be redefined each time as specified above.

- -

BOOST_VERIFY

-

<boost/assert.hpp> also defines the macro BOOST_VERIFY. - It has exactly the same behavior as BOOST_ASSERT, except that - the expression that is passed to BOOST_VERIFY 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.

-


- Copyright © 2002, 2007 by Peter Dimov.  Copyright © 2011 - by Beman Dawes. 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.

- - \ No newline at end of file diff --git a/assert_test.cpp b/assert_test.cpp deleted file mode 100644 index 26051ac..0000000 --- a/assert_test.cpp +++ /dev/null @@ -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 - -#include - -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 - -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 -#include -#include - -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(); -} diff --git a/current_function.html b/current_function.html deleted file mode 100644 index 373eb22..0000000 --- a/current_function.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - Boost: current_function.hpp documentation - - - - - - - - - - - -
boost.png (6897 bytes) - -

current_function.hpp

-
 
-

- The header <boost/current_function.hpp> defines a single - macro, BOOST_CURRENT_FUNCTION, similar to the - C99 predefined identifier __func__. -

-

BOOST_CURRENT_FUNCTION 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.

-

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.

-

-
- Copyright © 2002 by 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.

- - diff --git a/current_function_test.cpp b/current_function_test.cpp deleted file mode 100644 index 1343901..0000000 --- a/current_function_test.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include - -#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 -#include -#include - -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; -} diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp deleted file mode 100644 index ccc776a..0000000 --- a/include/boost/assert.hpp +++ /dev/null @@ -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 -#include - -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 // .h to support old libraries w/o - 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 - #include - - 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 - #include - #include - #include - - // 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 diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp deleted file mode 100644 index cb36e35..0000000 --- a/include/boost/current_function.hpp +++ /dev/null @@ -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 - diff --git a/index.html b/index.html index 98c82f1..e92da2a 100644 --- a/index.html +++ b/index.html @@ -15,13 +15,11 @@

addressof
- assert
base_from_member
BOOST_BINARY
call_traits
checked_delete
compressed_pair
- current_function
declval
enable_if
in_place_factory
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6fcf183..acf6329 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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/static : -u ] - [ run ../current_function_test.cpp : : : always_show_run_output ] [ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/static ] [ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/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 ] diff --git a/verify_test.cpp b/verify_test.cpp deleted file mode 100644 index 3481636..0000000 --- a/verify_test.cpp +++ /dev/null @@ -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 - -#include - -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 - -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 -#include -#include - -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(); -}