forked from boostorg/throw_exception
Update throw_from_library_test.cpp
This commit is contained in:
@ -31,9 +31,11 @@ run throw_exception_test5.cpp ;
|
|||||||
lib lib1_throw : lib1_throw.cpp : <define>LIB1_SOURCE=1 <link>shared:<define>LIB1_DYN_LINK=1 : : <link>shared:<define>LIB1_DYN_LINK=1 ;
|
lib lib1_throw : lib1_throw.cpp : <define>LIB1_SOURCE=1 <link>shared:<define>LIB1_DYN_LINK=1 : : <link>shared:<define>LIB1_DYN_LINK=1 ;
|
||||||
lib lib2_throw : lib2_throw.cpp : <define>LIB2_SOURCE=1 <link>shared:<define>LIB2_DYN_LINK=1 : : <link>shared:<define>LIB2_DYN_LINK=1 ;
|
lib lib2_throw : lib2_throw.cpp : <define>LIB2_SOURCE=1 <link>shared:<define>LIB2_DYN_LINK=1 : : <link>shared:<define>LIB2_DYN_LINK=1 ;
|
||||||
lib lib3_throw : lib3_throw.cpp : <define>LIB3_SOURCE=1 <link>shared:<define>LIB3_DYN_LINK=1 : : <link>shared:<define>LIB3_DYN_LINK=1 ;
|
lib lib3_throw : lib3_throw.cpp : <define>LIB3_SOURCE=1 <link>shared:<define>LIB3_DYN_LINK=1 : : <link>shared:<define>LIB3_DYN_LINK=1 ;
|
||||||
|
lib lib4_throw : lib4_throw.cpp : <define>LIB4_SOURCE=1 <link>shared:<define>LIB4_DYN_LINK=1 : : <link>shared:<define>LIB4_DYN_LINK=1 ;
|
||||||
|
lib lib5_throw : lib5_throw.cpp : <define>LIB5_SOURCE=1 <link>shared:<define>LIB5_DYN_LINK=1 : : <link>shared:<define>LIB5_DYN_LINK=1 ;
|
||||||
|
|
||||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>static : throw_from_library_static ;
|
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw lib5_throw : : : <link>static : throw_from_library_static ;
|
||||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>shared : throw_from_library_shared ;
|
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw lib5_throw : : : <link>shared : throw_from_library_shared ;
|
||||||
|
|
||||||
run throw_exception_nx_test.cpp : : : <exception-handling>off ;
|
run throw_exception_nx_test.cpp : : : <exception-handling>off ;
|
||||||
run throw_exception_nx_test2.cpp : : : <exception-handling>off ;
|
run throw_exception_nx_test2.cpp : : : <exception-handling>off ;
|
||||||
|
14
test/lib4_throw.cpp
Normal file
14
test/lib4_throw.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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 "lib4_throw.hpp"
|
||||||
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
void lib4::f()
|
||||||
|
{
|
||||||
|
boost::throw_exception( lib4::exception() );
|
||||||
|
}
|
36
test/lib4_throw.hpp
Normal file
36
test/lib4_throw.hpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef LIB4_THROW_HPP_INCLUDED
|
||||||
|
#define LIB4_THROW_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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/config.hpp>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#if defined(LIB4_DYN_LINK)
|
||||||
|
# if defined(LIB4_SOURCE)
|
||||||
|
# define LIB4_DECL BOOST_SYMBOL_EXPORT
|
||||||
|
# else
|
||||||
|
# define LIB4_DECL BOOST_SYMBOL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LIB4_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace lib4
|
||||||
|
{
|
||||||
|
|
||||||
|
struct BOOST_SYMBOL_VISIBLE exception: public std::exception, public boost::exception
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
LIB4_DECL void f();
|
||||||
|
|
||||||
|
} // namespace lib4
|
||||||
|
|
||||||
|
#endif // #ifndef LIB4_THROW_HPP_INCLUDED
|
14
test/lib5_throw.cpp
Normal file
14
test/lib5_throw.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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 "lib5_throw.hpp"
|
||||||
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
void lib5::f()
|
||||||
|
{
|
||||||
|
BOOST_THROW_EXCEPTION( lib5::exception() );
|
||||||
|
}
|
36
test/lib5_throw.hpp
Normal file
36
test/lib5_throw.hpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef LIB5_THROW_HPP_INCLUDED
|
||||||
|
#define LIB5_THROW_HPP_INCLUDED
|
||||||
|
|
||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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/config.hpp>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#if defined(LIB5_DYN_LINK)
|
||||||
|
# if defined(LIB5_SOURCE)
|
||||||
|
# define LIB5_DECL BOOST_SYMBOL_EXPORT
|
||||||
|
# else
|
||||||
|
# define LIB5_DECL BOOST_SYMBOL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LIB5_DECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace lib5
|
||||||
|
{
|
||||||
|
|
||||||
|
struct BOOST_SYMBOL_VISIBLE exception: public std::exception, public boost::exception
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
LIB5_DECL void f();
|
||||||
|
|
||||||
|
} // namespace lib5
|
||||||
|
|
||||||
|
#endif // #ifndef LIB5_THROW_HPP_INCLUDED
|
@ -20,6 +20,8 @@
|
|||||||
#include "lib1_throw.hpp"
|
#include "lib1_throw.hpp"
|
||||||
#include "lib2_throw.hpp"
|
#include "lib2_throw.hpp"
|
||||||
#include "lib3_throw.hpp"
|
#include "lib3_throw.hpp"
|
||||||
|
#include "lib4_throw.hpp"
|
||||||
|
#include "lib5_throw.hpp"
|
||||||
#include <boost/exception/exception.hpp>
|
#include <boost/exception/exception.hpp>
|
||||||
#include <boost/exception_ptr.hpp>
|
#include <boost/exception_ptr.hpp>
|
||||||
#include <boost/exception/get_error_info.hpp>
|
#include <boost/exception/get_error_info.hpp>
|
||||||
@ -30,12 +32,14 @@ void test_catch_by_type()
|
|||||||
BOOST_TEST_THROWS( lib1::f(), lib1::exception );
|
BOOST_TEST_THROWS( lib1::f(), lib1::exception );
|
||||||
BOOST_TEST_THROWS( lib2::f(), lib2::exception );
|
BOOST_TEST_THROWS( lib2::f(), lib2::exception );
|
||||||
BOOST_TEST_THROWS( lib3::f(), lib3::exception );
|
BOOST_TEST_THROWS( lib3::f(), lib3::exception );
|
||||||
|
BOOST_TEST_THROWS( lib4::f(), lib4::exception );
|
||||||
|
BOOST_TEST_THROWS( lib5::f(), lib5::exception );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_catch_by_exception()
|
void test_catch_by_exception()
|
||||||
{
|
{
|
||||||
BOOST_TEST_THROWS( lib2::f(), boost::exception );
|
BOOST_TEST_THROWS( lib4::f(), boost::exception );
|
||||||
BOOST_TEST_THROWS( lib3::f(), boost::exception );
|
BOOST_TEST_THROWS( lib5::f(), boost::exception );
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_exception_ptr()
|
void test_exception_ptr()
|
||||||
@ -49,7 +53,6 @@ void test_exception_ptr()
|
|||||||
boost::exception_ptr p = boost::current_exception();
|
boost::exception_ptr p = boost::current_exception();
|
||||||
|
|
||||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib2::exception );
|
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib2::exception );
|
||||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -61,6 +64,29 @@ void test_exception_ptr()
|
|||||||
boost::exception_ptr p = boost::current_exception();
|
boost::exception_ptr p = boost::current_exception();
|
||||||
|
|
||||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception );
|
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception );
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lib4::f();
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
boost::exception_ptr p = boost::current_exception();
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib4::exception );
|
||||||
|
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lib5::f();
|
||||||
|
}
|
||||||
|
catch( ... )
|
||||||
|
{
|
||||||
|
boost::exception_ptr p = boost::current_exception();
|
||||||
|
|
||||||
|
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib5::exception );
|
||||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,7 +95,7 @@ void test_throw_line()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lib3::f();
|
lib5::f();
|
||||||
}
|
}
|
||||||
catch( boost::exception const & x )
|
catch( boost::exception const & x )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user