forked from boostorg/conversion
Stop using assert() in tests
[SVN r33181]
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
#define BOOST_CAST_HPP
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <cassert>
|
||||
# include <boost/assert.hpp>
|
||||
# include <typeinfo>
|
||||
# include <boost/type.hpp>
|
||||
# include <boost/limits.hpp>
|
||||
@@ -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 <class Target, class Source>
|
||||
inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET)
|
||||
{
|
||||
assert( dynamic_cast<Target>(x) == x ); // detect logic error
|
||||
BOOST_ASSERT( dynamic_cast<Target>(x) == x ); // detect logic error
|
||||
return static_cast<Target>(x);
|
||||
}
|
||||
|
||||
|
@@ -4,9 +4,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/implicit_cast.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/type.hpp>
|
||||
|
||||
using boost::implicit_cast;
|
||||
using boost::type;
|
||||
|
||||
@@ -25,9 +24,9 @@ typedef type<foo> foo_type;
|
||||
int main()
|
||||
{
|
||||
type<long> x = check_return(boost::implicit_cast<long>(1));
|
||||
assert(boost::implicit_cast<long>(1) == 1L);
|
||||
BOOST_TEST(boost::implicit_cast<long>(1) == 1L);
|
||||
|
||||
type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
|
||||
type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user