From 80e9edcb29c03216992526b834e4cd3ff3154cbe Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 28 Feb 2006 22:56:33 +0000 Subject: [PATCH] Stop using assert() in tests [SVN r33181] --- include/boost/cast.hpp | 12 +++++++----- test/implicit_cast.cpp | 7 +++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp index 28b1eb1..2615d18 100644 --- a/include/boost/cast.hpp +++ b/include/boost/cast.hpp @@ -44,7 +44,7 @@ #define BOOST_CAST_HPP # include -# include +# include # include # include # include @@ -82,17 +82,19 @@ namespace boost // polymorphic_downcast ----------------------------------------------------// - // assert() checked polymorphic downcast. Crosscasts prohibited. + // BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited. - // WARNING: Because this cast uses assert(), it violates the One Definition - // Rule if NDEBUG is inconsistently defined across translation units. + // WARNING: Because this cast uses BOOST_ASSERT(), it violates + // the One Definition Rule if used in multiple translation units + // where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER + // NDEBUG are defined inconsistently. // Contributed by Dave Abrahams template inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) { - assert( dynamic_cast(x) == x ); // detect logic error + BOOST_ASSERT( dynamic_cast(x) == x ); // detect logic error return static_cast(x); } diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index 564c9eb..e18e17a 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -4,9 +4,8 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include - using boost::implicit_cast; using boost::type; @@ -25,9 +24,9 @@ typedef type foo_type; int main() { type x = check_return(boost::implicit_cast(1)); - assert(boost::implicit_cast(1) == 1L); + BOOST_TEST(boost::implicit_cast(1) == 1L); type f = check_return(boost::implicit_cast("hello")); type z = check_return(boost::implicit_cast(foo("hello"))); - return 0; + return boost::report_errors(); }