From a17f4bad42ba524ee4b3a08960029df04c077133 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 07:10:41 +0300 Subject: [PATCH] Add test that catches by boost::exception --- test/Jamfile.v2 | 2 ++ test/throw_exception_test2.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/throw_exception_test2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 28f75df..bfb1aa4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,6 +14,8 @@ run throw_exception_no_both_test.cpp ; compile-fail throw_exception_fail.cpp ; +run throw_exception_test2.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 ; diff --git a/test/throw_exception_test2.cpp b/test/throw_exception_test2.cpp new file mode 100644 index 0000000..c9d35de --- /dev/null +++ b/test/throw_exception_test2.cpp @@ -0,0 +1,28 @@ +// 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 + +class my_exception: public std::exception +{ +}; + +class my_exception2: public std::exception, public 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_exception() ), boost::exception ); + BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), boost::exception ); + + return boost::report_errors(); +}