diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 39782fd..28f75df 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,15 +7,16 @@ import testing ; -project - : requirements - static - on - ; - run throw_exception_test.cpp ; run throw_exception_no_exceptions_test.cpp ; run throw_exception_no_integration_test.cpp ; run throw_exception_no_both_test.cpp ; compile-fail throw_exception_fail.cpp ; + +lib lib1_throw : lib1_throw.cpp : LIB1_SOURCE=1 shared:LIB1_DYN_LINK=1 : : shared:LIB1_DYN_LINK=1 ; +lib lib2_throw : lib2_throw.cpp : LIB2_SOURCE=1 shared:LIB2_DYN_LINK=1 : : shared:LIB2_DYN_LINK=1 ; +lib lib3_throw : lib3_throw.cpp : LIB3_SOURCE=1 shared:LIB3_DYN_LINK=1 : : shared:LIB3_DYN_LINK=1 ; + +run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : static : throw_from_library_static ; +run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : shared : throw_from_library_shared ; diff --git a/test/lib1_throw.cpp b/test/lib1_throw.cpp new file mode 100644 index 0000000..4dadd17 --- /dev/null +++ b/test/lib1_throw.cpp @@ -0,0 +1,13 @@ +// 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 "lib1_throw.hpp" + +void lib1::f() +{ + throw lib1::exception(); +} diff --git a/test/lib1_throw.hpp b/test/lib1_throw.hpp new file mode 100644 index 0000000..4f960bf --- /dev/null +++ b/test/lib1_throw.hpp @@ -0,0 +1,35 @@ +#ifndef LIB1_THROW_HPP_INCLUDED +#define LIB1_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 +#include + +#if defined(LIB1_DYN_LINK) +# if defined(LIB1_SOURCE) +# define LIB1_DECL BOOST_SYMBOL_EXPORT +# else +# define LIB1_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define LIB1_DECL +#endif + +namespace lib1 +{ + +struct exception: public std::exception +{ +}; + +LIB1_DECL void f(); + +} // namespace lib1 + +#endif // #ifndef LIB1_THROW_HPP_INCLUDED diff --git a/test/lib2_throw.cpp b/test/lib2_throw.cpp new file mode 100644 index 0000000..fc1e442 --- /dev/null +++ b/test/lib2_throw.cpp @@ -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 "lib2_throw.hpp" +#include + +void lib2::f() +{ + boost::throw_exception( lib2::exception() ); +} diff --git a/test/lib2_throw.hpp b/test/lib2_throw.hpp new file mode 100644 index 0000000..9e85dea --- /dev/null +++ b/test/lib2_throw.hpp @@ -0,0 +1,35 @@ +#ifndef LIB2_THROW_HPP_INCLUDED +#define LIB2_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 +#include + +#if defined(LIB2_DYN_LINK) +# if defined(LIB2_SOURCE) +# define LIB2_DECL BOOST_SYMBOL_EXPORT +# else +# define LIB2_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define LIB2_DECL +#endif + +namespace lib2 +{ + +struct exception: public std::exception +{ +}; + +LIB2_DECL void f(); + +} // namespace lib2 + +#endif // #ifndef LIB2_THROW_HPP_INCLUDED diff --git a/test/lib3_throw.cpp b/test/lib3_throw.cpp new file mode 100644 index 0000000..eb7d348 --- /dev/null +++ b/test/lib3_throw.cpp @@ -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 "lib3_throw.hpp" +#include + +void lib3::f() +{ + BOOST_THROW_EXCEPTION( lib3::exception() ); +} diff --git a/test/lib3_throw.hpp b/test/lib3_throw.hpp new file mode 100644 index 0000000..5144b30 --- /dev/null +++ b/test/lib3_throw.hpp @@ -0,0 +1,35 @@ +#ifndef LIB3_THROW_HPP_INCLUDED +#define LIB3_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 +#include + +#if defined(LIB3_DYN_LINK) +# if defined(LIB3_SOURCE) +# define LIB3_DECL BOOST_SYMBOL_EXPORT +# else +# define LIB3_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define LIB3_DECL +#endif + +namespace lib3 +{ + +struct exception: public std::exception +{ +}; + +LIB3_DECL void f(); + +} // namespace lib3 + +#endif // #ifndef LIB3_THROW_HPP_INCLUDED diff --git a/test/throw_from_library_test.cpp b/test/throw_from_library_test.cpp new file mode 100644 index 0000000..154c3a6 --- /dev/null +++ b/test/throw_from_library_test.cpp @@ -0,0 +1,20 @@ +// 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 "lib1_throw.hpp" +#include "lib2_throw.hpp" +#include "lib3_throw.hpp" +#include + +int main() +{ + BOOST_TEST_THROWS( lib1::f(), lib1::exception ); + BOOST_TEST_THROWS( lib2::f(), lib2::exception ); + BOOST_TEST_THROWS( lib3::f(), lib3::exception ); + + return boost::report_errors(); +}