fixed compile errors, removed tabs as required.

[SVN r44114]
This commit is contained in:
Emil Dotchevski
2008-04-08 21:29:37 +00:00
parent e0881a603d
commit 0fbc4dc974
33 changed files with 1402 additions and 1404 deletions

View File

@ -9,32 +9,32 @@
namespace
test
{
class my_exception: public boost::exception { };
{
class my_exception: public boost::exception { };
typedef boost::error_info<struct tag_my_info,int> my_info;
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));
}
}
}
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();
}
{
test::test_boost_error_info();
return boost::report_errors();
}

View File

@ -8,35 +8,35 @@
struct
test_exception:
std::exception
{
};
std::exception
{
};
int
main()
{
try
{
throw boost::enable_exception_cloning(test_exception());
}
catch(
std::exception & x )
{
boost::exception_ptr p = boost::clone_exception(x);
try
{
rethrow_exception(p);
BOOST_TEST(false);
}
catch(
test_exception & )
{
}
catch(
... )
{
BOOST_TEST(false);
}
}
return boost::report_errors();
}
{
try
{
throw boost::enable_exception_cloning(test_exception());
}
catch(
std::exception & x )
{
boost::exception_ptr p = boost::clone_exception(x);
try
{
rethrow_exception(p);
BOOST_TEST(false);
}
catch(
test_exception & )
{
}
catch(
... )
{
BOOST_TEST(false);
}
}
return boost::report_errors();
}

View File

@ -8,42 +8,42 @@
#include <boost/detail/lightweight_test.hpp>
namespace
{
typedef boost::error_info<struct tag_test_int,int> test_int;
{
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;
}
}
}
void
throw_wrapper()
{
try
{
boost::exception_test::throw_length_error();
}
catch(
boost::exception & x )
{
x << test_int(42);
throw;
}
}
}
int
main()
{
try
{
throw_wrapper();
BOOST_TEST(false);
}
catch(
std::exception & x )
{
BOOST_TEST( 42==*boost::get_error_info<test_int>(x) );
}
catch(
... )
{
BOOST_TEST(false);
}
return boost::report_errors();
}
{
try
{
throw_wrapper();
BOOST_TEST(false);
}
catch(
std::exception & x )
{
BOOST_TEST( 42==*boost::get_error_info<test_int>(x) );
}
catch(
... )
{
BOOST_TEST(false);
}
return boost::report_errors();
}

View File

@ -11,23 +11,23 @@ typedef boost::error_info<struct tag_errno,int> info_errno;
class
my_exception:
public boost::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();
}
{
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();
}

View File

@ -18,200 +18,200 @@ typedef boost::error_info<struct tag_test_6,non_printable> test_6;
struct
test_exception:
public boost::exception
{
};
public boost::exception
{
};
struct
throws_on_copy
{
throws_on_copy()
{
}
{
throws_on_copy()
{
}
throws_on_copy( throws_on_copy const & )
{
throw test_exception();
}
};
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));
}
{
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));
}
{
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();
}
{
throw test_exception();
}
void
throw_test_1( char const * value )
{
throw test_exception() << test_5(std::string(value));
}
{
throw test_exception() << test_5(std::string(value));
}
void
throw_test_2()
{
throw test_exception() << test_6(non_printable());
}
{
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;
}
}
{
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) );
}
{
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) );
}
try
{
throw_empty();
BOOST_TEST(false);
}
catch(
test_exception & x )
{
BOOST_TEST( dynamic_cast<boost::exception *>(&x) );
}
}
try
{
throw_empty();
BOOST_TEST(false);
}
catch(
test_exception & x )
{
BOOST_TEST( dynamic_cast<boost::exception *>(&x) );
}
}
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"));
}
try
{
throw_test_2();
BOOST_ASSERT(false);
}
catch(
boost::exception & x )
{
BOOST_TEST(boost::get_error_info<test_6>(x));
}
}
{
try
{
throw_test_1("test");
BOOST_ASSERT(false);
}
catch(
boost::exception & x )
{
BOOST_TEST(*boost::get_error_info<test_5>(x)==std::string("test"));
}
try
{
throw_test_2();
BOOST_ASSERT(false);
}
catch(
boost::exception & x )
{
BOOST_TEST(boost::get_error_info<test_6>(x));
}
}
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"));
}
}
{
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"));
}
}
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 );
}
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 );
}
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" );
}
}
{
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 );
}
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 );
}
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" );
}
}
int
main()
{
basic_test();
exception_safety_test();
test_empty();
test_basic_throw_catch();
test_catch_add_info();
test_add_tuple();
return boost::report_errors();
}
{
basic_test();
exception_safety_test();
test_empty();
test_basic_throw_catch();
test_catch_add_info();
test_add_tuple();
return boost::report_errors();
}

View File

@ -7,6 +7,6 @@
void
tester( boost::exception & x )
{
throw x; //must not compile.
}
{
throw x; //must not compile.
}

View File

@ -8,28 +8,28 @@
class
test_exception:
public boost::exception
{
};
public boost::exception
{
};
void
test_throw()
{
throw test_exception();
}
{
throw test_exception();
}
int
main()
{
try
{
test_throw();
BOOST_TEST(false);
}
catch(
test_exception & )
{
BOOST_TEST(true);
}
return boost::report_errors();
}
{
try
{
test_throw();
BOOST_TEST(false);
}
catch(
test_exception & )
{
BOOST_TEST(true);
}
return boost::report_errors();
}

View File

@ -5,17 +5,18 @@
#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("my length error") );
}
}
}
{
namespace
exception_test
{
void
throw_length_error()
{
throw enable_error_info( std::length_error("my length error") );
}
}
}

View File

@ -8,12 +8,12 @@
namespace
boost
{
namespace
exception_test
{
void throw_length_error();
}
}
{
namespace
exception_test
{
void throw_length_error();
}
}
#endif

View File

@ -8,46 +8,46 @@
namespace
boost
{
namespace
exception_test
{
inline
some_boost_exception::
some_boost_exception( int x ):
x_(x)
{
}
{
namespace
exception_test
{
inline
some_boost_exception::
some_boost_exception( int x ):
x_(x)
{
}
some_boost_exception::
~some_boost_exception() throw()
{
}
some_boost_exception::
~some_boost_exception() throw()
{
}
inline
some_std_exception::
some_std_exception( int x ):
x_(x)
{
}
inline
some_std_exception::
some_std_exception( int x ):
x_(x)
{
}
some_std_exception::
~some_std_exception() throw()
{
}
some_std_exception::
~some_std_exception() throw()
{
}
template <>
void
throw_test_exception<some_boost_exception>( int x )
{
boost::throw_exception( some_boost_exception(x) );
}
template <>
void
throw_test_exception<some_boost_exception>( int x )
{
boost::throw_exception( some_boost_exception(x) );
}
template <>
void
throw_test_exception<some_std_exception>( int x )
{
boost::throw_exception( some_std_exception(x) );
}
}
}
template <>
void
throw_test_exception<some_std_exception>( int x )
{
boost::throw_exception( some_std_exception(x) );
}
}
}

View File

@ -10,38 +10,38 @@
namespace
boost
{
namespace
exception_test
{
struct
some_boost_exception:
public boost::exception,
public std::exception
{
explicit some_boost_exception( int x );
virtual ~some_boost_exception() throw();
int x_;
};
{
namespace
exception_test
{
struct
some_boost_exception:
public boost::exception,
public std::exception
{
explicit some_boost_exception( int x );
virtual ~some_boost_exception() throw();
int x_;
};
struct
some_std_exception:
public std::exception
{
explicit some_std_exception( int x );
virtual ~some_std_exception() throw();
int x_;
};
struct
some_std_exception:
public std::exception
{
explicit some_std_exception( int x );
virtual ~some_std_exception() throw();
int x_;
};
template <class>
void throw_test_exception( int );
template <class>
void throw_test_exception( int );
template <>
void throw_test_exception<some_boost_exception>( int );
template <>
void throw_test_exception<some_boost_exception>( int );
template <>
void throw_test_exception<some_std_exception>( int );
}
}
template <>
void throw_test_exception<some_std_exception>( int );
}
}
#endif

View File

@ -12,60 +12,60 @@ typedef boost::error_info<struct tag_test_int,int> test_int;
void
throw_fwd( void (*thrower)(int) )
{
try
{
thrower(42);
}
catch(
boost::exception & x )
{
x << test_int(42);
throw;
}
}
{
try
{
thrower(42);
}
catch(
boost::exception & x )
{
x << test_int(42);
throw;
}
}
template <class T>
void
tester()
{
try
{
throw_fwd( &boost::exception_test::throw_test_exception<T> );
BOOST_ASSERT(false);
}
catch(
std::exception & x )
{
boost::exception_ptr p = boost::clone_exception(x);
try
{
rethrow_exception(p);
BOOST_TEST(false);
}
catch(
T & y )
{
BOOST_TEST(*boost::get_error_info<test_int>(y)==42);
BOOST_TEST(y.x_==42);
}
catch(
... )
{
BOOST_TEST(false);
}
}
catch(
... )
{
BOOST_TEST(false);
}
}
{
try
{
throw_fwd( &boost::exception_test::throw_test_exception<T> );
BOOST_ASSERT(false);
}
catch(
std::exception & x )
{
boost::exception_ptr p = boost::clone_exception(x);
try
{
rethrow_exception(p);
BOOST_TEST(false);
}
catch(
T & y )
{
BOOST_TEST(*boost::get_error_info<test_int>(y)==42);
BOOST_TEST(y.x_==42);
}
catch(
... )
{
BOOST_TEST(false);
}
}
catch(
... )
{
BOOST_TEST(false);
}
}
int
main()
{
tester<boost::exception_test::some_boost_exception>();
tester<boost::exception_test::some_std_exception>();
return boost::report_errors();
}
{
tester<boost::exception_test::some_boost_exception>();
tester<boost::exception_test::some_std_exception>();
return boost::report_errors();
}

View File

@ -9,89 +9,89 @@
namespace
n1
{
class
c1
{
};
{
class
c1
{
};
std::string
to_string( c1 const & )
{
return "c1";
}
}
std::string
to_string( c1 const & )
{
return "c1";
}
}
namespace
n2
{
class
c2
{
};
{
class
c2
{
};
std::ostream &
operator<<( std::ostream & s, c2 const & )
{
s << "c2";
return s;
}
}
std::ostream &
operator<<( std::ostream & s, c2 const & )
{
s << "c2";
return s;
}
}
namespace
n3
{
class
c3
{
};
{
class
c3
{
};
std::ostream &
operator<<( std::ostream & s, c3 const & )
{
s << "bad";
return s;
}
std::ostream &
operator<<( std::ostream & s, c3 const & )
{
s << "bad";
return s;
}
std::string
to_string( c3 const & )
{
return "c3";
}
}
std::string
to_string( c3 const & )
{
return "c3";
}
}
namespace
boost
{
class
to_string_tester
{
};
}
{
class
to_string_tester
{
};
}
template <class T>
struct
my_stub
{
std::string
operator()( T const & )
{
return "stub";
}
};
{
std::string
operator()( T const & )
{
return "stub";
}
};
int
main()
{
using namespace boost;
BOOST_TEST( to_string(5)=="5" );
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(5)=="5" );
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" );
return boost::report_errors();
}
{
using namespace boost;
BOOST_TEST( to_string(5)=="5" );
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(5)=="5" );
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" );
return boost::report_errors();
}

View File

@ -11,74 +11,74 @@ typedef boost::error_info<struct tag_test,int> test;
struct
test_boost_exception:
boost::exception
{
};
boost::exception
{
};
void
throw_boost_exception()
{
throw test_boost_exception() << test(42);
}
{
throw test_boost_exception() << test(42);
}
void
throw_unknown_exception()
{
struct
test_exception:
std::exception
{
};
throw test_exception();
}
{
struct
test_exception:
std::exception
{
};
throw test_exception();
}
int
main()
{
try
{
throw_boost_exception();
}
catch(
boost::exception & x )
{
boost::exception_ptr ep=boost::clone_exception(x);
try
{
rethrow_exception(ep);
}
catch(
boost::unknown_exception & x )
{
BOOST_TEST( 42==*boost::get_error_info<test>(x) );
}
catch(
... )
{
BOOST_TEST(false);
}
}
try
{
throw_unknown_exception();
}
catch(
std::exception & x )
{
boost::exception_ptr ep=boost::clone_exception(x);
try
{
rethrow_exception(ep);
}
catch(
boost::unknown_exception & )
{
}
catch(
... )
{
BOOST_TEST(false);
}
}
return boost::report_errors();
}
{
try
{
throw_boost_exception();
}
catch(
boost::exception & x )
{
boost::exception_ptr ep=boost::clone_exception(x);
try
{
rethrow_exception(ep);
}
catch(
boost::unknown_exception & x )
{
BOOST_TEST( 42==*boost::get_error_info<test>(x) );
}
catch(
... )
{
BOOST_TEST(false);
}
}
try
{
throw_unknown_exception();
}
catch(
std::exception & x )
{
boost::exception_ptr ep=boost::clone_exception(x);
try
{
rethrow_exception(ep);
}
catch(
boost::unknown_exception & )
{
}
catch(
... )
{
BOOST_TEST(false);
}
}
return boost::report_errors();
}

View File

@ -10,18 +10,18 @@ typedef boost::error_info<struct tag_test,int> test;
class
my_exception:
public boost::exception
{
};
public boost::exception
{
};
int
main()
{
my_exception x;
x << test(1);
std::string w1 = x.what();
x << test(2);
std::string w2 = x.what();
BOOST_TEST( w1!=w2 );
return boost::report_errors();
}
{
my_exception x;
x << test(1);
std::string w1 = x.what();
x << test(2);
std::string w2 = x.what();
BOOST_TEST( w1!=w2 );
return boost::report_errors();
}