From 5b2acbc1759675ce84f50f665e3eac631a9f658f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 19 Oct 2018 04:04:06 +0300 Subject: [PATCH] Add throw/catch test for bad_function_call --- test/Jamfile.v2 | 5 +++++ test/test_bad_function_call.cpp | 14 ++++++++++++++ test/throw_bad_function_call.cpp | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 test/test_bad_function_call.cpp create mode 100644 test/throw_bad_function_call.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 9b9a1a11..7f5d2971 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -36,3 +36,8 @@ run nothrow_swap.cpp ; run rvalues_test.cpp ; compile function_typeof_test.cpp ; run result_arg_types_test.cpp ; + +lib throw_bad_function_call : throw_bad_function_call.cpp : shared:THROW_BAD_FUNCTION_CALL_DYN_LINK=1 ; + +run test_bad_function_call.cpp throw_bad_function_call : : : shared : test_bad_function_call_shared ; +run test_bad_function_call.cpp throw_bad_function_call : : : static : test_bad_function_call_static ; diff --git a/test/test_bad_function_call.cpp b/test/test_bad_function_call.cpp new file mode 100644 index 00000000..3c88dd39 --- /dev/null +++ b/test/test_bad_function_call.cpp @@ -0,0 +1,14 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +void throw_bad_function_call(); + +int main() +{ + BOOST_TEST_THROWS( throw_bad_function_call(), boost::bad_function_call ); + return boost::report_errors(); +} diff --git a/test/throw_bad_function_call.cpp b/test/throw_bad_function_call.cpp new file mode 100644 index 00000000..d6037592 --- /dev/null +++ b/test/throw_bad_function_call.cpp @@ -0,0 +1,17 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +#if defined(THROW_BAD_FUNCTION_CALL_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +EXPORT void throw_bad_function_call() +{ + throw boost::bad_function_call(); +}