summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/throw_exception/test
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/throw_exception/test
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/throw_exception/test')
-rw-r--r--src/boost/libs/throw_exception/test/Jamfile.v226
-rw-r--r--src/boost/libs/throw_exception/test/lib1_throw.cpp13
-rw-r--r--src/boost/libs/throw_exception/test/lib1_throw.hpp35
-rw-r--r--src/boost/libs/throw_exception/test/lib2_throw.cpp14
-rw-r--r--src/boost/libs/throw_exception/test/lib2_throw.hpp35
-rw-r--r--src/boost/libs/throw_exception/test/lib3_throw.cpp14
-rw-r--r--src/boost/libs/throw_exception/test/lib3_throw.hpp35
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_fail.cpp18
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_no_both_test.cpp28
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_no_exceptions_test.cpp27
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_no_integration_test.cpp30
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_test.cpp31
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_test2.cpp28
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_test3.cpp71
-rw-r--r--src/boost/libs/throw_exception/test/throw_exception_test4.cpp47
-rw-r--r--src/boost/libs/throw_exception/test/throw_from_library_test.cpp79
16 files changed, 531 insertions, 0 deletions
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 00000000..e28308d1
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/Jamfile.v2
@@ -0,0 +1,26 @@
+# Boost Exception Library test Jamfile
+#
+# 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)
+
+import testing ;
+
+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 ;
+
+run throw_exception_test2.cpp ;
+run throw_exception_test3.cpp ;
+run throw_exception_test4.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 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 ;
+
+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 : : : <link>shared : throw_from_library_shared ;
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 00000000..4dadd176
--- /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 00000000..f3d169b1
--- /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 <boost/config.hpp>
+#include <exception>
+
+#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 00000000..fc1e4424
--- /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 <boost/throw_exception.hpp>
+
+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 00000000..59e8dc27
--- /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 <boost/config.hpp>
+#include <exception>
+
+#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 00000000..eb7d348b
--- /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 <boost/throw_exception.hpp>
+
+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 00000000..da280ab6
--- /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 <boost/config.hpp>
+#include <exception>
+
+#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 00000000..9f34104e
--- /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 <boost/throw_exception.hpp>
+
+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 00000000..b7e673f5
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_exception_no_both_test.cpp
@@ -0,0 +1,28 @@
+//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 <boost/throw_exception.hpp>
+#include <cstdlib>
+
+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 00000000..467dab50
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_exception_no_exceptions_test.cpp
@@ -0,0 +1,27 @@
+//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 <boost/throw_exception.hpp>
+#include <cstdlib>
+
+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 00000000..6fa78f54
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_exception_no_integration_test.cpp
@@ -0,0 +1,30 @@
+//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 <boost/throw_exception.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+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_test.cpp b/src/boost/libs/throw_exception/test/throw_exception_test.cpp
new file mode 100644
index 00000000..5106e862
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_exception_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)
+
+#include <boost/throw_exception.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/config.hpp>
+
+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 00000000..c9d35dea
--- /dev/null
+++ b/src/boost/libs/throw_exception/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 <boost/throw_exception.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+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();
+}
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 00000000..7f20420a
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_exception_test3.cpp
@@ -0,0 +1,71 @@
+// 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/throw_exception.hpp>
+#include <boost/exception_ptr.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+class my_exception: public std::exception
+{
+};
+
+class my_exception2: public std::exception, public 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_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 );
+ }
+
+ 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 00000000..5b8e303e
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_exception_test4.cpp
@@ -0,0 +1,47 @@
+// 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/throw_exception.hpp>
+#include <boost/exception/get_error_info.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+class my_exception: public std::exception
+{
+};
+
+class my_exception2: public std::exception, public boost::exception
+{
+};
+
+int main()
+{
+ try
+ {
+ BOOST_THROW_EXCEPTION( my_exception() );
+ }
+ catch( boost::exception const & x )
+ {
+ int const * line = boost::get_error_info<boost::throw_line>( x );
+
+ BOOST_TEST( line != 0 );
+ BOOST_TEST_EQ( *line, 24 );
+ }
+
+ try
+ {
+ BOOST_THROW_EXCEPTION( my_exception2() );
+ }
+ catch( boost::exception const & x )
+ {
+ int const * line = boost::get_error_info<boost::throw_line>( x );
+
+ BOOST_TEST( line != 0 );
+ BOOST_TEST_EQ( *line, 36 );
+ }
+
+ 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 00000000..22a89da6
--- /dev/null
+++ b/src/boost/libs/throw_exception/test/throw_from_library_test.cpp
@@ -0,0 +1,79 @@
+// 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 <boost/exception/exception.hpp>
+#include <boost/exception_ptr.hpp>
+#include <boost/exception/get_error_info.hpp>
+#include <boost/core/lightweight_test.hpp>
+
+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<boost::throw_line>( 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();
+}