forked from boostorg/exception
added functions current_exception_cast, current_exception_diagnostic_information, various other minor changes, documentation update
[SVN r52236]
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Boost Exception Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
#
|
||||
# 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)
|
||||
@ -33,6 +33,8 @@ run errno_test.cpp ;
|
||||
run error_info_test.cpp ;
|
||||
run diagnostic_information_test.cpp ;
|
||||
run refcount_ptr_test.cpp ;
|
||||
run current_exception_cast_test.cpp ;
|
||||
run no_exceptions_test.cpp : : : <exception-handling>off ;
|
||||
compile-fail exception_fail.cpp ;
|
||||
compile-fail throw_exception_fail.cpp ;
|
||||
|
||||
@ -47,3 +49,4 @@ compile info_hpp_test.cpp ;
|
||||
compile info_tuple_hpp_test.cpp ;
|
||||
compile to_string_hpp_test.cpp ;
|
||||
compile to_string_stub_hpp_test.cpp ;
|
||||
compile current_exception_cast_hpp_test.cpp ;
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
@ -382,7 +382,7 @@ main()
|
||||
boost::unknown_exception & x )
|
||||
{
|
||||
BOOST_TEST(boost::get_error_info<my_info>(x));
|
||||
if( boost::shared_ptr<int const> p=boost::get_error_info<my_info>(x) )
|
||||
if( int const * p=boost::get_error_info<my_info>(x) )
|
||||
BOOST_TEST(*p==42);
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST(!(p==boost::exception_ptr()));
|
||||
@ -397,7 +397,7 @@ main()
|
||||
boost::unknown_exception & x )
|
||||
{
|
||||
BOOST_TEST(boost::get_error_info<my_info>(x));
|
||||
if( boost::shared_ptr<int const> p=boost::get_error_info<my_info>(x) )
|
||||
if( int const * p=boost::get_error_info<my_info>(x) )
|
||||
BOOST_TEST(*p==42);
|
||||
}
|
||||
catch(
|
||||
@ -433,7 +433,7 @@ main()
|
||||
boost::unknown_exception & x )
|
||||
{
|
||||
BOOST_TEST(boost::get_error_info<my_info>(x));
|
||||
if( boost::shared_ptr<int const> p=boost::get_error_info<my_info>(x) )
|
||||
if( int const * p=boost::get_error_info<my_info>(x) )
|
||||
BOOST_TEST(*p==42);
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST(!(p==boost::exception_ptr()));
|
||||
@ -448,7 +448,7 @@ main()
|
||||
boost::unknown_exception & x )
|
||||
{
|
||||
BOOST_TEST(boost::get_error_info<my_info>(x));
|
||||
if( boost::shared_ptr<int const> p=boost::get_error_info<my_info>(x) )
|
||||
if( int const * p=boost::get_error_info<my_info>(x) )
|
||||
BOOST_TEST(*p==42);
|
||||
}
|
||||
catch(
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
7
test/current_exception_cast_hpp_test.cpp
Normal file
7
test/current_exception_cast_hpp_test.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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/exception/current_exception_cast.hpp>
|
||||
#include <boost/exception/current_exception_cast.hpp>
|
47
test/current_exception_cast_test.cpp
Normal file
47
test/current_exception_cast_test.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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/exception/current_exception_cast.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <exception>
|
||||
|
||||
class
|
||||
my_exception:
|
||||
public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class
|
||||
polymorphic
|
||||
{
|
||||
virtual
|
||||
~polymorphic()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw my_exception();
|
||||
}
|
||||
catch(
|
||||
std::exception & e )
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch(
|
||||
...)
|
||||
{
|
||||
BOOST_TEST(boost::current_exception_cast<std::exception>()==&e);
|
||||
BOOST_TEST(!boost::current_exception_cast<polymorphic>());
|
||||
}
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
@ -27,8 +27,8 @@ to_string( tagged_int2 const & x )
|
||||
|
||||
struct
|
||||
error1:
|
||||
public std::exception,
|
||||
public boost::exception
|
||||
std::exception,
|
||||
boost::exception
|
||||
{
|
||||
char const *
|
||||
what() const throw()
|
||||
@ -39,10 +39,42 @@ error1:
|
||||
|
||||
struct
|
||||
error2:
|
||||
public boost::exception
|
||||
boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
void
|
||||
test1( std::string const & di1, std::string const & di2 )
|
||||
{
|
||||
BOOST_TEST( di1!=di2 );
|
||||
#ifndef BOOST_NO_RTTI
|
||||
BOOST_TEST(di1.find("type:")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("error1")!=std::string::npos);
|
||||
#endif
|
||||
BOOST_TEST(di1.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("fourty-two")!=std::string::npos);
|
||||
#ifndef BOOST_NO_RTTI
|
||||
BOOST_TEST(di2.find("type:")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("error1")!=std::string::npos);
|
||||
#endif
|
||||
BOOST_TEST(di2.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("bad value")!=std::string::npos);
|
||||
}
|
||||
|
||||
void
|
||||
test2( std::string const & di1, std::string const & di2 )
|
||||
{
|
||||
BOOST_TEST( di1!=di2 );
|
||||
BOOST_TEST(di1.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("fourty-two")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("bad value")!=std::string::npos);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@ -54,30 +86,26 @@ main()
|
||||
throw x;
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
error1 & x )
|
||||
{
|
||||
std::string di1=boost::diagnostic_information(x);
|
||||
x << tagged_int1(2) << tagged_int2(2);
|
||||
std::string di2 = diagnostic_information(x);
|
||||
#ifndef BOOST_NO_RTTI
|
||||
BOOST_TEST(di1.find("type:")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("error1")!=std::string::npos);
|
||||
#endif
|
||||
BOOST_TEST(di1.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("fourty-two")!=std::string::npos);
|
||||
#ifndef BOOST_NO_RTTI
|
||||
BOOST_TEST(di2.find("type:")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("error1")!=std::string::npos);
|
||||
#endif
|
||||
BOOST_TEST(di2.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("bad value")!=std::string::npos);
|
||||
test1(di1,di2);
|
||||
}
|
||||
try
|
||||
{
|
||||
error1 x; x << tagged_int1(42) << tagged_int2(42);
|
||||
BOOST_TEST(x.what()==std::string("error1"));
|
||||
throw x;
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
error1 & x )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
std::string di1=boost::current_exception_diagnostic_information();
|
||||
x << tagged_int1(2) << tagged_int2(2);
|
||||
std::string di2 = current_exception_diagnostic_information();
|
||||
test1(di1,di2);
|
||||
}
|
||||
try
|
||||
{
|
||||
@ -86,23 +114,26 @@ main()
|
||||
throw x;
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
error2 & x )
|
||||
{
|
||||
std::string di1 = diagnostic_information(x);
|
||||
x << tagged_int1(2) << tagged_int2(2);
|
||||
std::string di2 = diagnostic_information(x);
|
||||
BOOST_TEST( di1!=di2 );
|
||||
BOOST_TEST(di1.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di1.find("fourty-two")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("test_tag1")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("test_tag2")!=std::string::npos);
|
||||
BOOST_TEST(di2.find("bad value")!=std::string::npos);
|
||||
test2(di1,di2);
|
||||
}
|
||||
try
|
||||
{
|
||||
error2 x;
|
||||
x << tagged_int1(42) << tagged_int2(42);
|
||||
throw x;
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
error2 & x )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
std::string di1 = current_exception_diagnostic_information();
|
||||
x << tagged_int1(2) << tagged_int2(2);
|
||||
std::string di2 = current_exception_diagnostic_information();
|
||||
test2(di1,di2);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
@ -55,7 +55,7 @@ main()
|
||||
{
|
||||
#endif
|
||||
BOOST_TEST( boost::get_error_info<test_int>(x) );
|
||||
if( boost::shared_ptr<int const> p=boost::get_error_info<test_int>(x) )
|
||||
if( int const * p=boost::get_error_info<test_int>(x) )
|
||||
BOOST_TEST( 42==*p );
|
||||
#ifdef BOOST_NO_RTTI
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
40
test/no_exceptions_test.cpp
Normal file
40
test/no_exceptions_test.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
||||
#define BOOST_NO_EXCEPTIONS
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct my_exception: boost::exception, std::exception { };
|
||||
typedef boost::error_info<struct my_tag,int> my_int;
|
||||
|
||||
bool called=false;
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
void
|
||||
throw_exception( std::exception const & x )
|
||||
{
|
||||
called=true;
|
||||
std::string s=boost::diagnostic_information(x);
|
||||
std::cout << s;
|
||||
#ifndef BOOST_NO_RTTI
|
||||
BOOST_TEST(s.find("my_tag")!=std::string::npos);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() << my_int(42) );
|
||||
BOOST_TEST(called);
|
||||
return boost::report_errors();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
@ -35,9 +35,9 @@ boost_throw_exception_test()
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
boost::shared_ptr<char const * const> file=boost::get_error_info<boost::throw_function>(x);
|
||||
boost::shared_ptr<char const * const> function=boost::get_error_info<boost::throw_file>(x);
|
||||
boost::shared_ptr<int const> line=boost::get_error_info<boost::throw_line>(x);
|
||||
char const * const * file=boost::get_error_info<boost::throw_function>(x);
|
||||
char const * const * function=boost::get_error_info<boost::throw_file>(x);
|
||||
int const * line=boost::get_error_info<boost::throw_line>(x);
|
||||
BOOST_TEST( file && *file );
|
||||
BOOST_TEST( function && *function );
|
||||
BOOST_TEST( line && *line==32 );
|
||||
@ -55,10 +55,10 @@ boost_throw_exception_test()
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
boost::shared_ptr<char const * const> file=boost::get_error_info<boost::throw_function>(x);
|
||||
boost::shared_ptr<char const * const> function=boost::get_error_info<boost::throw_file>(x);
|
||||
boost::shared_ptr<int const> line=boost::get_error_info<boost::throw_line>(x);
|
||||
boost::shared_ptr<int const> data=boost::get_error_info<test_data>(x);
|
||||
char const * const * file=boost::get_error_info<boost::throw_function>(x);
|
||||
char const * const * function=boost::get_error_info<boost::throw_file>(x);
|
||||
int const * line=boost::get_error_info<boost::throw_line>(x);
|
||||
int const * data=boost::get_error_info<test_data>(x);
|
||||
BOOST_TEST( file && *file );
|
||||
BOOST_TEST( function && *function );
|
||||
BOOST_TEST( line && *line==52 );
|
||||
@ -117,7 +117,7 @@ tester()
|
||||
{
|
||||
#endif
|
||||
BOOST_TEST(boost::get_error_info<test_data>(y));
|
||||
if( boost::shared_ptr<int const> d=boost::get_error_info<test_data>(y) )
|
||||
if( int const * d=boost::get_error_info<test_data>(y) )
|
||||
BOOST_TEST(*d==42);
|
||||
#ifdef BOOST_NO_RTTI
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
|
||||
//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)
|
||||
@ -56,7 +56,7 @@ main()
|
||||
catch(
|
||||
boost::unknown_exception & x )
|
||||
{
|
||||
if( boost::shared_ptr<int const> d=boost::get_error_info<test>(x) )
|
||||
if( int const * d=boost::get_error_info<test>(x) )
|
||||
BOOST_TEST( 42==*d );
|
||||
else
|
||||
BOOST_TEST(false);
|
||||
@ -73,7 +73,7 @@ main()
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
if( boost::shared_ptr<int const> d=boost::get_error_info<test>(x) )
|
||||
if( int const * d=boost::get_error_info<test>(x) )
|
||||
BOOST_TEST( 42==*d );
|
||||
else
|
||||
BOOST_TEST(false);
|
||||
|
Reference in New Issue
Block a user