From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/throw_exception/test/CMakeLists.txt | 17 +++ src/boost/libs/throw_exception/test/Jamfile.v2 | 39 +++++++ .../test/cmake_install_test/CMakeLists.txt | 17 +++ .../test/cmake_install_test/main.cpp | 19 ++++ .../test/cmake_subdir_test/CMakeLists.txt | 19 ++++ .../test/cmake_subdir_test/main.cpp | 19 ++++ src/boost/libs/throw_exception/test/lib1_throw.cpp | 13 +++ src/boost/libs/throw_exception/test/lib1_throw.hpp | 35 ++++++ src/boost/libs/throw_exception/test/lib2_throw.cpp | 14 +++ src/boost/libs/throw_exception/test/lib2_throw.hpp | 35 ++++++ src/boost/libs/throw_exception/test/lib3_throw.cpp | 14 +++ src/boost/libs/throw_exception/test/lib3_throw.hpp | 35 ++++++ .../throw_exception/test/throw_exception_fail.cpp | 18 ++++ .../test/throw_exception_no_both_test.cpp | 32 ++++++ .../test/throw_exception_no_exceptions_test.cpp | 31 ++++++ .../test/throw_exception_no_integration_test.cpp | 34 ++++++ .../test/throw_exception_nx_test.cpp | 29 +++++ .../test/throw_exception_nx_test2.cpp | 35 ++++++ .../throw_exception/test/throw_exception_test.cpp | 34 ++++++ .../throw_exception/test/throw_exception_test2.cpp | 38 +++++++ .../throw_exception/test/throw_exception_test3.cpp | 111 +++++++++++++++++++ .../throw_exception/test/throw_exception_test4.cpp | 111 +++++++++++++++++++ .../throw_exception/test/throw_exception_test5.cpp | 119 +++++++++++++++++++++ .../test/throw_from_library_test.cpp | 91 ++++++++++++++++ 24 files changed, 959 insertions(+) create mode 100644 src/boost/libs/throw_exception/test/CMakeLists.txt create mode 100644 src/boost/libs/throw_exception/test/Jamfile.v2 create mode 100644 src/boost/libs/throw_exception/test/cmake_install_test/CMakeLists.txt create mode 100644 src/boost/libs/throw_exception/test/cmake_install_test/main.cpp create mode 100644 src/boost/libs/throw_exception/test/cmake_subdir_test/CMakeLists.txt create mode 100644 src/boost/libs/throw_exception/test/cmake_subdir_test/main.cpp create mode 100644 src/boost/libs/throw_exception/test/lib1_throw.cpp create mode 100644 src/boost/libs/throw_exception/test/lib1_throw.hpp create mode 100644 src/boost/libs/throw_exception/test/lib2_throw.cpp create mode 100644 src/boost/libs/throw_exception/test/lib2_throw.hpp create mode 100644 src/boost/libs/throw_exception/test/lib3_throw.cpp create mode 100644 src/boost/libs/throw_exception/test/lib3_throw.hpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_fail.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_no_both_test.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_no_exceptions_test.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_no_integration_test.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_nx_test.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_nx_test2.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_test.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_test2.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_test3.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_test4.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_exception_test5.cpp create mode 100644 src/boost/libs/throw_exception/test/throw_from_library_test.cpp (limited to 'src/boost/libs/throw_exception/test') diff --git a/src/boost/libs/throw_exception/test/CMakeLists.txt b/src/boost/libs/throw_exception/test/CMakeLists.txt new file mode 100644 index 000000000..486b61fc6 --- /dev/null +++ b/src/boost/libs/throw_exception/test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018, 2019 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(HAVE_BOOST_TEST) + +boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::throw_exception Boost::core Boost::exception) + +endif() + +#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 ; + +#run throw_exception_nx_test.cpp : : : off ; +#run throw_exception_nx_test2.cpp : : : off ; diff --git a/src/boost/libs/throw_exception/test/Jamfile.v2 b/src/boost/libs/throw_exception/test/Jamfile.v2 new file mode 100644 index 000000000..0fa060e32 --- /dev/null +++ b/src/boost/libs/throw_exception/test/Jamfile.v2 @@ -0,0 +1,39 @@ +# Boost ThrowException Library test Jamfile +# +# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. +# Copyright 2019 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) + +import testing ; + +project : requirements + extra + msvc:on + clang:on + gcc:on + gcc:-Wshadow ; + +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 + : off ; + +run throw_exception_test2.cpp ; +run throw_exception_test3.cpp ; +run throw_exception_test4.cpp ; +run throw_exception_test5.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 ; + +run throw_exception_nx_test.cpp : : : off ; +run throw_exception_nx_test2.cpp : : : off ; diff --git a/src/boost/libs/throw_exception/test/cmake_install_test/CMakeLists.txt b/src/boost/libs/throw_exception/test/cmake_install_test/CMakeLists.txt new file mode 100644 index 000000000..d48c3ec60 --- /dev/null +++ b/src/boost/libs/throw_exception/test/cmake_install_test/CMakeLists.txt @@ -0,0 +1,17 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_install_test LANGUAGES CXX) + +find_package(boost_throw_exception REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main Boost::throw_exception) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/libs/throw_exception/test/cmake_install_test/main.cpp b/src/boost/libs/throw_exception/test/cmake_install_test/main.cpp new file mode 100644 index 000000000..771931e3c --- /dev/null +++ b/src/boost/libs/throw_exception/test/cmake_install_test/main.cpp @@ -0,0 +1,19 @@ +// Copyright 2019 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 + +int main() +{ + try + { + boost::throw_exception( std::runtime_error( "" ) ); + return 1; + } + catch( std::runtime_error const& ) + { + return 0; + } +} diff --git a/src/boost/libs/throw_exception/test/cmake_subdir_test/CMakeLists.txt b/src/boost/libs/throw_exception/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 000000000..eca331b59 --- /dev/null +++ b/src/boost/libs/throw_exception/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,19 @@ +# 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 + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../../../assert boostorg/assert) +add_subdirectory(../../../config boostorg/config) +add_subdirectory(../../../throw_exception boostorg/throw_exception) + +add_executable(main main.cpp) +target_link_libraries(main Boost::throw_exception) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/src/boost/libs/throw_exception/test/cmake_subdir_test/main.cpp b/src/boost/libs/throw_exception/test/cmake_subdir_test/main.cpp new file mode 100644 index 000000000..771931e3c --- /dev/null +++ b/src/boost/libs/throw_exception/test/cmake_subdir_test/main.cpp @@ -0,0 +1,19 @@ +// Copyright 2019 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 + +int main() +{ + try + { + boost::throw_exception( std::runtime_error( "" ) ); + return 1; + } + catch( std::runtime_error const& ) + { + return 0; + } +} diff --git a/src/boost/libs/throw_exception/test/lib1_throw.cpp b/src/boost/libs/throw_exception/test/lib1_throw.cpp new file mode 100644 index 000000000..4dadd176b --- /dev/null +++ b/src/boost/libs/throw_exception/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/src/boost/libs/throw_exception/test/lib1_throw.hpp b/src/boost/libs/throw_exception/test/lib1_throw.hpp new file mode 100644 index 000000000..f3d169b13 --- /dev/null +++ b/src/boost/libs/throw_exception/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 BOOST_SYMBOL_VISIBLE exception: public std::exception +{ +}; + +LIB1_DECL void f(); + +} // namespace lib1 + +#endif // #ifndef LIB1_THROW_HPP_INCLUDED diff --git a/src/boost/libs/throw_exception/test/lib2_throw.cpp b/src/boost/libs/throw_exception/test/lib2_throw.cpp new file mode 100644 index 000000000..fc1e4424f --- /dev/null +++ b/src/boost/libs/throw_exception/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/src/boost/libs/throw_exception/test/lib2_throw.hpp b/src/boost/libs/throw_exception/test/lib2_throw.hpp new file mode 100644 index 000000000..59e8dc27e --- /dev/null +++ b/src/boost/libs/throw_exception/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 BOOST_SYMBOL_VISIBLE exception: public std::exception +{ +}; + +LIB2_DECL void f(); + +} // namespace lib2 + +#endif // #ifndef LIB2_THROW_HPP_INCLUDED diff --git a/src/boost/libs/throw_exception/test/lib3_throw.cpp b/src/boost/libs/throw_exception/test/lib3_throw.cpp new file mode 100644 index 000000000..eb7d348bb --- /dev/null +++ b/src/boost/libs/throw_exception/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/src/boost/libs/throw_exception/test/lib3_throw.hpp b/src/boost/libs/throw_exception/test/lib3_throw.hpp new file mode 100644 index 000000000..da280ab65 --- /dev/null +++ b/src/boost/libs/throw_exception/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 BOOST_SYMBOL_VISIBLE exception: public std::exception +{ +}; + +LIB3_DECL void f(); + +} // namespace lib3 + +#endif // #ifndef LIB3_THROW_HPP_INCLUDED diff --git a/src/boost/libs/throw_exception/test/throw_exception_fail.cpp b/src/boost/libs/throw_exception/test/throw_exception_fail.cpp new file mode 100644 index 000000000..9f34104ec --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_fail.cpp @@ -0,0 +1,18 @@ +//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 + +struct +my_exception + { + }; + +void +tester() + { + //Must not compile, throw_exception requires exception types to derive std::exception. + boost::throw_exception(my_exception()); + } diff --git a/src/boost/libs/throw_exception/test/throw_exception_no_both_test.cpp b/src/boost/libs/throw_exception/test/throw_exception_no_both_test.cpp new file mode 100644 index 000000000..e87695a98 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_no_both_test.cpp @@ -0,0 +1,32 @@ +//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 +#define BOOST_EXCEPTION_DISABLE + +#include +#include + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +class my_exception: public std::exception {}; + +int main() +{ + boost::throw_exception( my_exception() ); + return 1; +} + +namespace boost +{ + +void throw_exception( std::exception const & ) +{ + std::exit( 0 ); +} + +} // namespace boost diff --git a/src/boost/libs/throw_exception/test/throw_exception_no_exceptions_test.cpp b/src/boost/libs/throw_exception/test/throw_exception_no_exceptions_test.cpp new file mode 100644 index 000000000..8bfb95e7c --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_no_exceptions_test.cpp @@ -0,0 +1,31 @@ +//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 +#include + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +class my_exception: public std::exception {}; + +int main() +{ + boost::throw_exception( my_exception() ); + return 1; +} + +namespace boost +{ + +void throw_exception( std::exception const & ) +{ + std::exit( 0 ); +} + +} // namespace boost diff --git a/src/boost/libs/throw_exception/test/throw_exception_no_integration_test.cpp b/src/boost/libs/throw_exception/test/throw_exception_no_integration_test.cpp new file mode 100644 index 000000000..b2c499d91 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_no_integration_test.cpp @@ -0,0 +1,34 @@ +//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_EXCEPTION_DISABLE +#include +#include + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +class my_exception: public std::exception { }; + +int +main() + { + try + { + boost::throw_exception(my_exception()); + BOOST_ERROR("boost::throw_exception failed to throw."); + } + catch( + my_exception & ) + { + } + catch( + ... ) + { + BOOST_ERROR("boost::throw_exception malfunction."); + } + return boost::report_errors(); + } diff --git a/src/boost/libs/throw_exception/test/throw_exception_nx_test.cpp b/src/boost/libs/throw_exception/test/throw_exception_nx_test.cpp new file mode 100644 index 000000000..f6ac51513 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_nx_test.cpp @@ -0,0 +1,29 @@ +// Copyright 2019 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +# pragma warning(disable: 4577) // noexcept used without /EHsc +#endif + +#include +#include + +class my_exception: public std::exception {}; + +int main() +{ + boost::throw_exception( my_exception() ); + return 1; +} + +namespace boost +{ + +void throw_exception( std::exception const & ) +{ + std::exit( 0 ); +} + +} // namespace boost diff --git a/src/boost/libs/throw_exception/test/throw_exception_nx_test2.cpp b/src/boost/libs/throw_exception/test/throw_exception_nx_test2.cpp new file mode 100644 index 000000000..aabe3808e --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_nx_test2.cpp @@ -0,0 +1,35 @@ +// Copyright 2019 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +# pragma warning(disable: 4577) // noexcept used without /EHsc +#endif + +#include +#include +#include + +class my_exception: public std::exception {}; + +int main() +{ + BOOST_THROW_EXCEPTION( my_exception() ); + return 1; +} + +namespace boost +{ + +void throw_exception( std::exception const &, boost::source_location const & loc ) +{ + int r = 0; + + if( std::strcmp( loc.file_name(), __FILE__ ) != 0 ) ++r; + if( loc.line() != 18 ) ++r; + + std::exit( r ); +} + +} // namespace boost diff --git a/src/boost/libs/throw_exception/test/throw_exception_test.cpp b/src/boost/libs/throw_exception/test/throw_exception_test.cpp new file mode 100644 index 000000000..89031e8a7 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_test.cpp @@ -0,0 +1,34 @@ +//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 +#include +#include + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +class my_exception: public std::exception { }; + +int +main() + { + try + { + boost::throw_exception(my_exception()); + BOOST_ERROR("boost::throw_exception failed to throw."); + } + catch( + my_exception & ) + { + } + catch( + ... ) + { + BOOST_ERROR("boost::throw_exception malfunction."); + } + return boost::report_errors(); + } diff --git a/src/boost/libs/throw_exception/test/throw_exception_test2.cpp b/src/boost/libs/throw_exception/test/throw_exception_test2.cpp new file mode 100644 index 000000000..0655a6405 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_test2.cpp @@ -0,0 +1,38 @@ +// 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(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public boost::exception +{ +}; + +class my_exception3: public std::exception, public virtual boost::exception +{ +}; + +int main() +{ + BOOST_TEST_THROWS( boost::throw_exception( my_exception() ), boost::exception ); + BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), boost::exception ); + BOOST_TEST_THROWS( boost::throw_exception( my_exception3() ), boost::exception ); + + BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception() ), boost::exception ); + BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), boost::exception ); + BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception3() ), boost::exception ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/throw_exception/test/throw_exception_test3.cpp b/src/boost/libs/throw_exception/test/throw_exception_test3.cpp new file mode 100644 index 000000000..3e8077328 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_test3.cpp @@ -0,0 +1,111 @@ +// 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 + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wunknown-warning-option" +# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression" +# pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor" +# pragma clang diagnostic ignored "-Wunused-parameter" +#endif + +#include +#include +#include + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public boost::exception +{ +}; + +class my_exception3: public std::exception, public virtual boost::exception +{ +}; + +int main() +{ + try + { + boost::throw_exception( my_exception() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + boost::throw_exception( my_exception2() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception2 ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + boost::throw_exception( my_exception3() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception3 ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + BOOST_THROW_EXCEPTION( my_exception() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + BOOST_THROW_EXCEPTION( my_exception2() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception2 ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + BOOST_THROW_EXCEPTION( my_exception3() ); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception3 ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/throw_exception/test/throw_exception_test4.cpp b/src/boost/libs/throw_exception/test/throw_exception_test4.cpp new file mode 100644 index 000000000..1a0eb8152 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_test4.cpp @@ -0,0 +1,111 @@ +// 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 +#include + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public boost::exception +{ +}; + +class my_exception3: public std::exception, public virtual boost::exception +{ +}; + +int main() +{ + try + { + BOOST_THROW_EXCEPTION( my_exception() ); + } + catch( boost::exception const & x ) + { + { + char const * const * file = boost::get_error_info( x ); + + BOOST_TEST( file != 0 ); + BOOST_TEST_CSTR_EQ( *file, __FILE__ ); + } + + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 28 ); + } + + { + char const * const * function = boost::get_error_info( x ); + + BOOST_TEST( function != 0 ); + BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION ); + } + } + + try + { + BOOST_THROW_EXCEPTION( my_exception2() ); + } + catch( boost::exception const & x ) + { + { + char const * const * file = boost::get_error_info( x ); + + BOOST_TEST( file != 0 ); + BOOST_TEST_CSTR_EQ( *file, __FILE__ ); + } + + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 56 ); + } + + { + char const * const * function = boost::get_error_info( x ); + + BOOST_TEST( function != 0 ); + BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION ); + } + } + + try + { + BOOST_THROW_EXCEPTION( my_exception3() ); + } + catch( boost::exception const & x ) + { + { + char const * const * file = boost::get_error_info( x ); + + BOOST_TEST( file != 0 ); + BOOST_TEST_CSTR_EQ( *file, __FILE__ ); + } + + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 84 ); + } + + { + char const * const * function = boost::get_error_info( x ); + + BOOST_TEST( function != 0 ); + BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION ); + } + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/throw_exception/test/throw_exception_test5.cpp b/src/boost/libs/throw_exception/test/throw_exception_test5.cpp new file mode 100644 index 000000000..32970cf88 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_exception_test5.cpp @@ -0,0 +1,119 @@ +// Copyright 2018, 2019 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 + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wunknown-warning-option" +# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression" +# pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor" +#endif + +#include +#include +#include +#include +#include + +typedef boost::error_info error_code; +typedef boost::error_info error_string; + +class my_exception: public std::exception, public boost::exception +{ +}; + +class my_exception2: public std::exception, public virtual boost::exception +{ +}; + +int main() +{ + try + { + boost::throw_exception( my_exception() << error_code( 123 ) << error_string( "error%%string" ) ); + } + catch( boost::exception const & x ) + { + { + int const * code = boost::get_error_info( x ); + + BOOST_TEST( code != 0 ); + BOOST_TEST_EQ( *code, 123 ); + } + + { + std::string const * str = boost::get_error_info( x ); + + BOOST_TEST( str != 0 ); + BOOST_TEST_EQ( *str, "error%%string" ); + } + } + + try + { + BOOST_THROW_EXCEPTION( my_exception() << error_code( 123 ) << error_string( "error%%string" ) ); + } + catch( boost::exception const & x ) + { + { + int const * code = boost::get_error_info( x ); + + BOOST_TEST( code != 0 ); + BOOST_TEST_EQ( *code, 123 ); + } + + { + std::string const * str = boost::get_error_info( x ); + + BOOST_TEST( str != 0 ); + BOOST_TEST_EQ( *str, "error%%string" ); + } + } + + try + { + boost::throw_exception( my_exception2() << error_code( 123 ) << error_string( "error%%string" ) ); + } + catch( boost::exception const & x ) + { + { + int const * code = boost::get_error_info( x ); + + BOOST_TEST( code != 0 ); + BOOST_TEST_EQ( *code, 123 ); + } + + { + std::string const * str = boost::get_error_info( x ); + + BOOST_TEST( str != 0 ); + BOOST_TEST_EQ( *str, "error%%string" ); + } + } + + try + { + BOOST_THROW_EXCEPTION( my_exception2() << error_code( 123 ) << error_string( "error%%string" ) ); + } + catch( boost::exception const & x ) + { + { + int const * code = boost::get_error_info( x ); + + BOOST_TEST( code != 0 ); + BOOST_TEST_EQ( *code, 123 ); + } + + { + std::string const * str = boost::get_error_info( x ); + + BOOST_TEST( str != 0 ); + BOOST_TEST_EQ( *str, "error%%string" ); + } + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/throw_exception/test/throw_from_library_test.cpp b/src/boost/libs/throw_exception/test/throw_from_library_test.cpp new file mode 100644 index 000000000..af2a673e4 --- /dev/null +++ b/src/boost/libs/throw_exception/test/throw_from_library_test.cpp @@ -0,0 +1,91 @@ +// 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 + +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunknown-pragmas" +# pragma clang diagnostic ignored "-Wunknown-warning-option" +# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression" +# pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor" +# pragma clang diagnostic ignored "-Wunused-parameter" +#endif + +#include "lib1_throw.hpp" +#include "lib2_throw.hpp" +#include "lib3_throw.hpp" +#include +#include +#include +#include + +void test_catch_by_type() +{ + BOOST_TEST_THROWS( lib1::f(), lib1::exception ); + BOOST_TEST_THROWS( lib2::f(), lib2::exception ); + BOOST_TEST_THROWS( lib3::f(), lib3::exception ); +} + +void test_catch_by_exception() +{ + BOOST_TEST_THROWS( lib2::f(), boost::exception ); + BOOST_TEST_THROWS( lib3::f(), boost::exception ); +} + +void test_exception_ptr() +{ + try + { + lib2::f(); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib2::exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } + + try + { + lib3::f(); + } + catch( ... ) + { + boost::exception_ptr p = boost::current_exception(); + + BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception ); + BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception ); + } +} + +void test_throw_line() +{ + try + { + lib3::f(); + } + catch( boost::exception const & x ) + { + int const * line = boost::get_error_info( x ); + + BOOST_TEST( line != 0 ); + BOOST_TEST_EQ( *line, 13 ); + } +} + +int main() +{ + test_catch_by_type(); + test_catch_by_exception(); + test_exception_ptr(); + test_throw_line(); + + return boost::report_errors(); +} -- cgit v1.2.3