mirror of
https://github.com/boostorg/exception.git
synced 2025-07-16 05:52:14 +02:00
Boost Exception
In other libraries, watch for compile error referring to throw_exception_assert_compatibility in boost::throw_exception. Resolve by throwing an exception that derives from std::exception. This is not a new requirement but it is being enforced now. [SVN r46818]
This commit is contained in:
47
test/Jamfile.v2
Normal file
47
test/Jamfile.v2
Normal file
@ -0,0 +1,47 @@
|
||||
# Boost Exception Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2006-2008 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)
|
||||
|
||||
import testing ;
|
||||
|
||||
project : requirements <exception-handling>on ;
|
||||
|
||||
#to_string
|
||||
|
||||
run is_output_streamable_test.cpp ;
|
||||
run has_to_string_test.cpp ;
|
||||
run to_string_test.cpp ;
|
||||
run to_string_stub_test.cpp ;
|
||||
compile-fail to_string_fail.cpp ;
|
||||
|
||||
#exception
|
||||
|
||||
run cloning_test.cpp ;
|
||||
run copy_exception_test.cpp ;
|
||||
run unknown_exception_test.cpp ;
|
||||
run exception_test.cpp ;
|
||||
run boost_error_info_test.cpp ;
|
||||
run enable_error_info_test.cpp helper1.cpp ;
|
||||
run throw_exception_test.cpp helper2.cpp ;
|
||||
run errno_test.cpp ;
|
||||
run error_info_test.cpp ;
|
||||
run diagnostic_information_test.cpp ;
|
||||
run what_test.cpp ;
|
||||
compile-fail exception_fail.cpp ;
|
||||
compile-fail throw_exception_fail.cpp ;
|
||||
|
||||
#headers
|
||||
|
||||
compile exception_ptr_hpp_test.cpp ;
|
||||
compile diagnostic_information_hpp_test.cpp ;
|
||||
compile enable_current_exception_hpp_test.cpp ;
|
||||
compile enable_error_info_hpp_test.cpp ;
|
||||
compile error_info_hpp_test.cpp ;
|
||||
compile exception_hpp_test.cpp ;
|
||||
compile info_hpp_test.cpp ;
|
||||
compile info_tuple_hpp_test.cpp ;
|
||||
compile to_string_hpp_test.cpp ;
|
||||
compile to_string_stub_hpp_test.cpp ;
|
40
test/boost_error_info_test.cpp
Normal file
40
test/boost_error_info_test.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
//Copyright (c) 2006-2008 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/info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace
|
||||
test
|
||||
{
|
||||
class my_exception: public boost::exception { };
|
||||
|
||||
typedef boost::error_info<struct tag_my_info,int> my_info;
|
||||
|
||||
void
|
||||
test_boost_error_info()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw my_exception() << BOOST_ERROR_INFO << my_info(1);
|
||||
}
|
||||
catch(
|
||||
my_exception & x )
|
||||
{
|
||||
BOOST_TEST(1==*boost::get_error_info<my_info>(x));
|
||||
BOOST_TEST(boost::get_error_info<boost::throw_function>(x));
|
||||
BOOST_TEST(boost::get_error_info<boost::throw_file>(x));
|
||||
BOOST_TEST(boost::get_error_info<boost::throw_line>(x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test::test_boost_error_info();
|
||||
return boost::report_errors();
|
||||
}
|
42
test/cloning_test.cpp
Normal file
42
test/cloning_test.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
//Copyright (c) 2006-2008 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_ptr.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct
|
||||
test_exception:
|
||||
std::exception
|
||||
{
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw boost::enable_current_exception(test_exception());
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
try
|
||||
{
|
||||
rethrow_exception(p);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
test_exception & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
34
test/copy_exception_test.cpp
Normal file
34
test/copy_exception_test.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
//Copyright (c) 2006-2008 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_ptr.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct
|
||||
test_exception:
|
||||
std::exception
|
||||
{
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
boost::exception_ptr p = boost::copy_exception(test_exception());
|
||||
try
|
||||
{
|
||||
rethrow_exception(p);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
test_exception & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
6
test/diagnostic_information_hpp_test.cpp
Normal file
6
test/diagnostic_information_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/diagnostic_information.hpp>
|
80
test/diagnostic_information_test.cpp
Normal file
80
test/diagnostic_information_test.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
//Copyright (c) 2006-2008 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/diagnostic_information.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
typedef boost::error_info<struct tag,int> tag_int;
|
||||
|
||||
struct
|
||||
error1:
|
||||
public std::exception
|
||||
{
|
||||
char const *
|
||||
what() const throw()
|
||||
{
|
||||
return "error1";
|
||||
}
|
||||
};
|
||||
|
||||
struct
|
||||
error2:
|
||||
public std::exception,
|
||||
public boost::exception
|
||||
{
|
||||
char const *
|
||||
what() const throw()
|
||||
{
|
||||
return "error2";
|
||||
}
|
||||
};
|
||||
|
||||
struct
|
||||
error3:
|
||||
public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
std::string
|
||||
get_diagnostic_information( std::exception const & x )
|
||||
{
|
||||
return boost::diagnostic_information(x);
|
||||
}
|
||||
|
||||
std::string
|
||||
get_what( std::exception const & x )
|
||||
{
|
||||
return x.what();
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
{
|
||||
error1 x;
|
||||
BOOST_TEST(get_what(x)=="error1");
|
||||
std::string di=get_diagnostic_information(x);
|
||||
BOOST_TEST(di.find("type:")!=std::string::npos);
|
||||
BOOST_TEST(di.find("error1")!=std::string::npos);
|
||||
}
|
||||
{
|
||||
error2 x; x << tag_int(42);
|
||||
BOOST_TEST(get_what(x)=="error2");
|
||||
std::string di=get_diagnostic_information(x);
|
||||
BOOST_TEST(di.find("type:")!=std::string::npos);
|
||||
BOOST_TEST(di.find("error2")!=std::string::npos);
|
||||
}
|
||||
{
|
||||
error3 x;
|
||||
x << tag_int(1);
|
||||
std::string w1 = x.diagnostic_information();
|
||||
x << tag_int(2);
|
||||
std::string w2 = x.diagnostic_information();
|
||||
BOOST_TEST( w1!=w2 );
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
6
test/enable_current_exception_hpp_test.cpp
Normal file
6
test/enable_current_exception_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/enable_current_exception.hpp>
|
6
test/enable_error_info_hpp_test.cpp
Normal file
6
test/enable_error_info_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/enable_error_info.hpp>
|
57
test/enable_error_info_test.cpp
Normal file
57
test/enable_error_info_test.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
//Copyright (c) 2006-2008 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 "helper1.hpp"
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef boost::error_info<struct tag_test_int,int> test_int;
|
||||
|
||||
void
|
||||
throw_wrapper()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::exception_test::throw_length_error();
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
x << test_int(42);
|
||||
throw;
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_wrapper();
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
std::exception & x )
|
||||
{
|
||||
BOOST_TEST( 42==*boost::get_error_info<test_int>(x) );
|
||||
BOOST_TEST( std::string(x.what())==std::string("exception test length error") );
|
||||
BOOST_TEST( std::string(x.what())!=std::string(boost::diagnostic_information(x)) );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
33
test/errno_test.cpp
Normal file
33
test/errno_test.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
//Copyright (c) 2006-2008 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/info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <errno.h>
|
||||
|
||||
typedef boost::error_info<struct tag_errno,int> info_errno;
|
||||
|
||||
class
|
||||
my_exception:
|
||||
public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try
|
||||
{
|
||||
errno=1;
|
||||
throw my_exception() << info_errno(errno);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
my_exception & x )
|
||||
{
|
||||
BOOST_TEST(1==*boost::get_error_info<info_errno>(x));
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
6
test/error_info_hpp_test.cpp
Normal file
6
test/error_info_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/error_info.hpp>
|
258
test/error_info_test.cpp
Normal file
258
test/error_info_test.cpp
Normal file
@ -0,0 +1,258 @@
|
||||
//Copyright (c) 2006-2008 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/info_tuple.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct throws_on_copy;
|
||||
struct non_printable { };
|
||||
|
||||
typedef boost::error_info<struct tag_test_1,int> test_1;
|
||||
typedef boost::error_info<struct tag_test_2,unsigned int> test_2;
|
||||
typedef boost::error_info<struct tag_test_3,float> test_3;
|
||||
typedef boost::error_info<struct tag_test_4,throws_on_copy> test_4;
|
||||
typedef boost::error_info<struct tag_test_5,std::string> test_5;
|
||||
typedef boost::error_info<struct tag_test_6,non_printable> test_6;
|
||||
|
||||
struct
|
||||
test_exception:
|
||||
boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
struct
|
||||
throws_on_copy
|
||||
{
|
||||
throws_on_copy()
|
||||
{
|
||||
}
|
||||
|
||||
throws_on_copy( throws_on_copy const & )
|
||||
{
|
||||
throw test_exception();
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
basic_test()
|
||||
{
|
||||
test_exception x;
|
||||
x << test_1(1) << test_2(2u) << test_3(3.14159f);
|
||||
BOOST_TEST(*boost::get_error_info<test_1>(x)==1);
|
||||
BOOST_TEST(*boost::get_error_info<test_2>(x)==2u);
|
||||
BOOST_TEST(*boost::get_error_info<test_3>(x)==3.14159f);
|
||||
BOOST_TEST(!boost::get_error_info<test_4>(x));
|
||||
}
|
||||
|
||||
void
|
||||
exception_safety_test()
|
||||
{
|
||||
test_exception x;
|
||||
try
|
||||
{
|
||||
x << test_4(throws_on_copy());
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
test_exception & )
|
||||
{
|
||||
}
|
||||
BOOST_TEST(!boost::get_error_info<test_4>(x));
|
||||
}
|
||||
|
||||
void
|
||||
throw_empty()
|
||||
{
|
||||
throw test_exception();
|
||||
}
|
||||
|
||||
void
|
||||
throw_test_1( char const * value )
|
||||
{
|
||||
throw test_exception() << test_5(std::string(value));
|
||||
}
|
||||
|
||||
void
|
||||
throw_test_2()
|
||||
{
|
||||
throw test_exception() << test_6(non_printable());
|
||||
}
|
||||
|
||||
void
|
||||
throw_catch_add_file_name( char const * name )
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_empty();
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
x << test_5(std::string(name));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_empty()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_empty();
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
BOOST_TEST( dynamic_cast<test_exception *>(&x) );
|
||||
BOOST_TEST( !boost::get_error_info<test_1>(x) );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw_empty();
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
{
|
||||
BOOST_TEST( dynamic_cast<boost::exception *>(&x) );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_basic_throw_catch()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_test_1("test");
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
BOOST_TEST(*boost::get_error_info<test_5>(x)==std::string("test"));
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw_test_2();
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
BOOST_TEST(boost::get_error_info<test_6>(x));
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_catch_add_info()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_catch_add_file_name("test");
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
BOOST_TEST(*boost::get_error_info<test_5>(x)==std::string("test"));
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_add_tuple()
|
||||
{
|
||||
typedef boost::tuple<test_1,test_2> test_12;
|
||||
typedef boost::tuple<test_1,test_2,test_3> test_123;
|
||||
typedef boost::tuple<test_1,test_2,test_3,test_5> test_1235;
|
||||
try
|
||||
{
|
||||
throw test_exception() << test_12(42,42u);
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
{
|
||||
BOOST_TEST( *boost::get_error_info<test_1>(x)==42 );
|
||||
BOOST_TEST( *boost::get_error_info<test_2>(x)==42u );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
try
|
||||
{
|
||||
throw test_exception() << test_123(42,42u,42.0f);
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
{
|
||||
BOOST_TEST( *boost::get_error_info<test_1>(x)==42 );
|
||||
BOOST_TEST( *boost::get_error_info<test_2>(x)==42u );
|
||||
BOOST_TEST( *boost::get_error_info<test_3>(x)==42.0f );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
try
|
||||
{
|
||||
throw test_exception() << test_1235(42,42u,42.0f,std::string("42"));
|
||||
}
|
||||
catch(
|
||||
test_exception & x )
|
||||
{
|
||||
BOOST_TEST( *boost::get_error_info<test_1>(x)==42 );
|
||||
BOOST_TEST( *boost::get_error_info<test_2>(x)==42u );
|
||||
BOOST_TEST( *boost::get_error_info<test_3>(x)==42.0f );
|
||||
BOOST_TEST( *boost::get_error_info<test_5>(x)=="42" );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
basic_test();
|
||||
exception_safety_test();
|
||||
test_empty();
|
||||
test_basic_throw_catch();
|
||||
test_catch_add_info();
|
||||
test_add_tuple();
|
||||
return boost::report_errors();
|
||||
}
|
12
test/exception_fail.cpp
Normal file
12
test/exception_fail.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
//Copyright (c) 2006-2008 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/exception.hpp>
|
||||
|
||||
void
|
||||
tester( boost::exception & x )
|
||||
{
|
||||
throw x; //must not compile.
|
||||
}
|
6
test/exception_hpp_test.cpp
Normal file
6
test/exception_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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.hpp>
|
6
test/exception_ptr_hpp_test.cpp
Normal file
6
test/exception_ptr_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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_ptr.hpp>
|
35
test/exception_test.cpp
Normal file
35
test/exception_test.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//Copyright (c) 2006-2008 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/exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
class
|
||||
test_exception:
|
||||
public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
void
|
||||
test_throw()
|
||||
{
|
||||
throw test_exception();
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try
|
||||
{
|
||||
test_throw();
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
test_exception & )
|
||||
{
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
57
test/has_to_string_test.cpp
Normal file
57
test/has_to_string_test.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
//Copyright (c) 2006-2008 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/to_string.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
namespace
|
||||
n1
|
||||
{
|
||||
struct
|
||||
c1
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
n2
|
||||
{
|
||||
struct
|
||||
c2
|
||||
{
|
||||
};
|
||||
|
||||
std::string
|
||||
to_string( c2 const & )
|
||||
{
|
||||
return "c2";
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
n3
|
||||
{
|
||||
struct
|
||||
c3
|
||||
{
|
||||
};
|
||||
|
||||
std::ostream &
|
||||
operator<<( std::ostream & s, c3 const & )
|
||||
{
|
||||
return s << "c3";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
BOOST_TEST( !has_to_string<n1::c1>::value );
|
||||
BOOST_TEST( has_to_string<n2::c2>::value );
|
||||
BOOST_TEST( has_to_string<n3::c3>::value );
|
||||
BOOST_TEST( has_to_string<int>::value );
|
||||
return boost::report_errors();
|
||||
}
|
22
test/helper1.cpp
Normal file
22
test/helper1.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
//Copyright (c) 2006-2008 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/enable_error_info.hpp>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
namespace
|
||||
exception_test
|
||||
{
|
||||
void
|
||||
throw_length_error()
|
||||
{
|
||||
throw enable_error_info( std::length_error("exception test length error") );
|
||||
}
|
||||
}
|
||||
}
|
19
test/helper1.hpp
Normal file
19
test/helper1.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
//Copyright (c) 2006-2008 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)
|
||||
|
||||
#ifndef UUID_4AEB7924CA2E11DC888A8C9355D89593
|
||||
#define UUID_4AEB7924CA2E11DC888A8C9355D89593
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
namespace
|
||||
exception_test
|
||||
{
|
||||
void throw_length_error();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
72
test/helper2.cpp
Normal file
72
test/helper2.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
//Copyright (c) 2006-2008 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 "helper2.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
namespace
|
||||
exception_test
|
||||
{
|
||||
inline
|
||||
derives_boost_exception::
|
||||
derives_boost_exception( int x ):
|
||||
x_(x)
|
||||
{
|
||||
}
|
||||
|
||||
derives_boost_exception::
|
||||
~derives_boost_exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
derives_boost_exception_virtually::
|
||||
derives_boost_exception_virtually( int x ):
|
||||
x_(x)
|
||||
{
|
||||
}
|
||||
|
||||
derives_boost_exception_virtually::
|
||||
~derives_boost_exception_virtually() throw()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
derives_std_exception::
|
||||
derives_std_exception( int x ):
|
||||
x_(x)
|
||||
{
|
||||
}
|
||||
|
||||
derives_std_exception::
|
||||
~derives_std_exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
throw_test_exception<derives_boost_exception>( int x )
|
||||
{
|
||||
boost::throw_exception( derives_boost_exception(x) );
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
throw_test_exception<derives_boost_exception_virtually>( int x )
|
||||
{
|
||||
boost::throw_exception( derives_boost_exception_virtually(x) );
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
throw_test_exception<derives_std_exception>( int x )
|
||||
{
|
||||
boost::throw_exception( derives_std_exception(x) );
|
||||
}
|
||||
}
|
||||
}
|
61
test/helper2.hpp
Normal file
61
test/helper2.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
//Copyright (c) 2006-2008 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)
|
||||
|
||||
#ifndef UUID_BC765EB4CA2A11DCBDC5828355D89593
|
||||
#define UUID_BC765EB4CA2A11DCBDC5828355D89593
|
||||
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <exception>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
namespace
|
||||
exception_test
|
||||
{
|
||||
struct
|
||||
derives_boost_exception:
|
||||
public boost::exception,
|
||||
public std::exception
|
||||
{
|
||||
explicit derives_boost_exception( int x );
|
||||
virtual ~derives_boost_exception() throw();
|
||||
int x_;
|
||||
};
|
||||
|
||||
struct
|
||||
derives_boost_exception_virtually:
|
||||
public virtual boost::exception,
|
||||
public std::exception
|
||||
{
|
||||
explicit derives_boost_exception_virtually( int x );
|
||||
virtual ~derives_boost_exception_virtually() throw();
|
||||
int x_;
|
||||
};
|
||||
|
||||
struct
|
||||
derives_std_exception:
|
||||
public std::exception
|
||||
{
|
||||
explicit derives_std_exception( int x );
|
||||
virtual ~derives_std_exception() throw();
|
||||
int x_;
|
||||
};
|
||||
|
||||
template <class>
|
||||
void throw_test_exception( int );
|
||||
|
||||
template <>
|
||||
void throw_test_exception<derives_boost_exception>( int );
|
||||
|
||||
template <>
|
||||
void throw_test_exception<derives_boost_exception_virtually>( int );
|
||||
|
||||
template <>
|
||||
void throw_test_exception<derives_std_exception>( int );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
6
test/info_hpp_test.cpp
Normal file
6
test/info_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/info.hpp>
|
6
test/info_tuple_hpp_test.cpp
Normal file
6
test/info_tuple_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/info_tuple.hpp>
|
41
test/is_output_streamable_test.cpp
Normal file
41
test/is_output_streamable_test.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
//Copyright (c) 2006-2008 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/detail/is_output_streamable.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
namespace
|
||||
n1
|
||||
{
|
||||
class
|
||||
c1
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
n2
|
||||
{
|
||||
class
|
||||
c2
|
||||
{
|
||||
};
|
||||
|
||||
std::ostream &
|
||||
operator<<( std::ostream & s, c2 const & )
|
||||
{
|
||||
s << "c2";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
BOOST_TEST( !boost::is_output_streamable<n1::c1>::value );
|
||||
BOOST_TEST( boost::is_output_streamable<n2::c2>::value );
|
||||
BOOST_TEST( boost::is_output_streamable<int>::value );
|
||||
return boost::report_errors();
|
||||
}
|
18
test/throw_exception_fail.cpp
Normal file
18
test/throw_exception_fail.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
//Copyright (c) 2006-2008 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/throw_exception.hpp>
|
||||
|
||||
struct
|
||||
my_exception
|
||||
{
|
||||
};
|
||||
|
||||
void
|
||||
tester()
|
||||
{
|
||||
//Must not compile, throw_exception requires exception types to derive std::exception.
|
||||
boost::throw_exception(my_exception());
|
||||
}
|
69
test/throw_exception_test.cpp
Normal file
69
test/throw_exception_test.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
//Copyright (c) 2006-2008 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 "helper2.hpp"
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
typedef boost::error_info<struct tag_test_int,int> test_data;
|
||||
|
||||
void
|
||||
throw_fwd( void (*thrower)(int) )
|
||||
{
|
||||
try
|
||||
{
|
||||
thrower(42);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
x << test_data(42);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
tester()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_fwd( &boost::exception_test::throw_test_exception<T> );
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
try
|
||||
{
|
||||
rethrow_exception(p);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
T & y )
|
||||
{
|
||||
BOOST_TEST(boost::get_error_info<test_data>(y));
|
||||
if( boost::shared_ptr<int const> d=boost::get_error_info<test_data>(y) )
|
||||
BOOST_TEST(*d==42);
|
||||
BOOST_TEST(y.x_==42);
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
tester<boost::exception_test::derives_boost_exception>();
|
||||
tester<boost::exception_test::derives_boost_exception_virtually>();
|
||||
tester<boost::exception_test::derives_std_exception>();
|
||||
return boost::report_errors();
|
||||
}
|
23
test/to_string_fail.cpp
Normal file
23
test/to_string_fail.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
//Copyright (c) 2006-2008 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/to_string.hpp>
|
||||
|
||||
namespace
|
||||
n1
|
||||
{
|
||||
struct
|
||||
c1
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
tester()
|
||||
{
|
||||
using namespace boost;
|
||||
(void) to_string(n1::c1());
|
||||
return 1;
|
||||
}
|
6
test/to_string_hpp_test.cpp
Normal file
6
test/to_string_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/to_string.hpp>
|
6
test/to_string_stub_hpp_test.cpp
Normal file
6
test/to_string_stub_hpp_test.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//Copyright (c) 2006-2008 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/to_string_stub.hpp>
|
98
test/to_string_stub_test.cpp
Normal file
98
test/to_string_stub_test.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
//Copyright (c) 2006-2008 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/to_string_stub.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
n1
|
||||
{
|
||||
class
|
||||
c1
|
||||
{
|
||||
};
|
||||
|
||||
std::string
|
||||
to_string( c1 const & )
|
||||
{
|
||||
return "c1";
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
n2
|
||||
{
|
||||
class
|
||||
c2
|
||||
{
|
||||
};
|
||||
|
||||
std::ostream &
|
||||
operator<<( std::ostream & s, c2 const & )
|
||||
{
|
||||
s << "c2";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
n3
|
||||
{
|
||||
class
|
||||
c3
|
||||
{
|
||||
};
|
||||
|
||||
std::ostream &
|
||||
operator<<( std::ostream & s, c3 const & )
|
||||
{
|
||||
s << "bad";
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string
|
||||
to_string( c3 const & )
|
||||
{
|
||||
return "c3";
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
class
|
||||
to_string_tester
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct
|
||||
my_stub
|
||||
{
|
||||
std::string
|
||||
operator()( T const & )
|
||||
{
|
||||
return "stub";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
BOOST_TEST( to_string(42)=="42" );
|
||||
BOOST_TEST( to_string(n1::c1())=="c1" );
|
||||
BOOST_TEST( to_string(n2::c2())=="c2" );
|
||||
BOOST_TEST( to_string(n3::c3())=="c3" );
|
||||
BOOST_TEST( to_string_stub(42)=="42" );
|
||||
BOOST_TEST( to_string_stub(n1::c1())=="c1" );
|
||||
BOOST_TEST( to_string_stub(n2::c2())=="c2" );
|
||||
BOOST_TEST( to_string_stub(n3::c3())=="c3" );
|
||||
BOOST_TEST( to_string_stub(to_string_tester(),my_stub<to_string_tester>())=="stub" );
|
||||
BOOST_TEST( !to_string_stub(to_string_tester()).empty() );
|
||||
return boost::report_errors();
|
||||
}
|
56
test/to_string_test.cpp
Normal file
56
test/to_string_test.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
//Copyright (c) 2006-2008 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/to_string.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
namespace
|
||||
n1
|
||||
{
|
||||
struct
|
||||
c1
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
n2
|
||||
{
|
||||
struct
|
||||
c2
|
||||
{
|
||||
};
|
||||
|
||||
std::string
|
||||
to_string( c2 const & )
|
||||
{
|
||||
return "c2";
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
n3
|
||||
{
|
||||
struct
|
||||
c3
|
||||
{
|
||||
};
|
||||
|
||||
std::ostream &
|
||||
operator<<( std::ostream & s, c3 const & )
|
||||
{
|
||||
return s << "c3";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
BOOST_TEST( "c2"==to_string(n2::c2()) );
|
||||
BOOST_TEST( "c3"==to_string(n3::c3()) );
|
||||
BOOST_TEST( "42"==to_string(42) );
|
||||
return boost::report_errors();
|
||||
}
|
117
test/unknown_exception_test.cpp
Normal file
117
test/unknown_exception_test.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
//Copyright (c) 2006-2008 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_ptr.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
typedef boost::error_info<struct tag_test,int> test;
|
||||
|
||||
struct
|
||||
test_boost_exception:
|
||||
boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
void
|
||||
throw_boost_exception()
|
||||
{
|
||||
throw test_boost_exception() << test(42);
|
||||
}
|
||||
|
||||
void
|
||||
throw_unknown_exception()
|
||||
{
|
||||
struct
|
||||
test_exception:
|
||||
std::exception
|
||||
{
|
||||
};
|
||||
throw test_exception();
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_boost_exception();
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
boost::exception_ptr ep=boost::current_exception();
|
||||
try
|
||||
{
|
||||
rethrow_exception(ep);
|
||||
}
|
||||
catch(
|
||||
boost::unknown_exception & x )
|
||||
{
|
||||
if( boost::shared_ptr<int const> d=boost::get_error_info<test>(x) )
|
||||
BOOST_TEST( 42==*d );
|
||||
else
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
try
|
||||
{
|
||||
rethrow_exception(ep);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
{
|
||||
if( boost::shared_ptr<int const> d=boost::get_error_info<test>(x) )
|
||||
BOOST_TEST( 42==*d );
|
||||
else
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
throw_unknown_exception();
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
boost::exception_ptr ep=boost::current_exception();
|
||||
try
|
||||
{
|
||||
rethrow_exception(ep);
|
||||
}
|
||||
catch(
|
||||
boost::unknown_exception & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
try
|
||||
{
|
||||
rethrow_exception(ep);
|
||||
}
|
||||
catch(
|
||||
boost::exception & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
32
test/what_test.cpp
Normal file
32
test/what_test.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
//Copyright (c) 2006-2008 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/exception.hpp>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
struct
|
||||
test_exception:
|
||||
std::exception,
|
||||
boost::exception
|
||||
{
|
||||
char const *
|
||||
what() const throw()
|
||||
{
|
||||
return "test_exception";
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test_exception x;
|
||||
std::exception & sx(x);
|
||||
boost::exception & bx(x);
|
||||
BOOST_TEST(std::string(sx.what())=="test_exception");
|
||||
BOOST_TEST(std::string(bx.what())=="test_exception");
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user