summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/exception/test/unknown_exception_test.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/exception/test/unknown_exception_test.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/exception/test/unknown_exception_test.cpp')
-rw-r--r--src/boost/libs/exception/test/unknown_exception_test.cpp142
1 files changed, 142 insertions, 0 deletions
diff --git a/src/boost/libs/exception/test/unknown_exception_test.cpp b/src/boost/libs/exception/test/unknown_exception_test.cpp
new file mode 100644
index 00000000..bf474ba1
--- /dev/null
+++ b/src/boost/libs/exception/test/unknown_exception_test.cpp
@@ -0,0 +1,142 @@
+//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 <boost/exception_ptr.hpp>
+#include <boost/exception/get_error_info.hpp>
+#include <boost/exception/info.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
+struct tag_test {};
+#endif
+
+typedef boost::error_info<struct tag_test,int> test;
+
+struct
+test_boost_exception:
+ boost::exception
+ {
+ };
+
+void
+throw_boost_exception()
+ {
+ throw test_boost_exception() << test(42);
+ }
+
+void
+throw_unknown_exception()
+ {
+ struct
+ test_exception:
+ std::exception
+ {
+ };
+ throw test_exception();
+ }
+
+int
+main()
+ {
+ try
+ {
+ throw_boost_exception();
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr ep=boost::current_exception();
+ try
+ {
+ rethrow_exception(ep);
+ }
+ catch(
+ boost::unknown_exception & x )
+ {
+ if( int const * d=boost::get_error_info<test>(x) )
+ BOOST_TEST( 42==*d );
+ else
+ BOOST_TEST(false);
+ }
+ catch(
+ boost::exception & x )
+ {
+ //Yay! Non-intrusive cloning supported!
+ if( int const * d=boost::get_error_info<test>(x) )
+ BOOST_TEST( 42==*d );
+ else
+ BOOST_TEST(false);
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ try
+ {
+ rethrow_exception(ep);
+ }
+ catch(
+ boost::exception & x )
+ {
+ if( int const * d=boost::get_error_info<test>(x) )
+ BOOST_TEST( 42==*d );
+ else
+ BOOST_TEST(false);
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+ try
+ {
+ throw_unknown_exception();
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr ep=boost::current_exception();
+ try
+ {
+ rethrow_exception(ep);
+ }
+ catch(
+ boost::unknown_exception & )
+ {
+ }
+ catch(
+ std::exception & )
+ {
+ //Yay! Non-intrusive cloning supported!
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ try
+ {
+ rethrow_exception(ep);
+ }
+ catch(
+ boost::exception & )
+ {
+ }
+ catch(
+ std::exception & )
+ {
+ //Yay! Non-intrusive cloning supported!
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+ return boost::report_errors();
+ }