Skip to content

Commit 5b2acbc

Browse files
pdimovjeking3
authored andcommitted
Add throw/catch test for bad_function_call
1 parent 755d3c2 commit 5b2acbc

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

test/Jamfile.v2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ run nothrow_swap.cpp ;
3636
run rvalues_test.cpp ;
3737
compile function_typeof_test.cpp ;
3838
run result_arg_types_test.cpp ;
39+
40+
lib throw_bad_function_call : throw_bad_function_call.cpp : <link>shared:<define>THROW_BAD_FUNCTION_CALL_DYN_LINK=1 ;
41+
42+
run test_bad_function_call.cpp throw_bad_function_call : : : <link>shared : test_bad_function_call_shared ;
43+
run test_bad_function_call.cpp throw_bad_function_call : : : <link>static : test_bad_function_call_static ;

test/test_bad_function_call.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
// Copyright 2018 Peter Dimov.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
5+
#include <boost/function.hpp>
6+
#include <boost/core/lightweight_test.hpp>
7+
8+
void throw_bad_function_call();
9+
10+
int main()
11+
{
12+
BOOST_TEST_THROWS( throw_bad_function_call(), boost::bad_function_call );
13+
return boost::report_errors();
14+
}

test/throw_bad_function_call.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
// Copyright 2018 Peter Dimov.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
5+
#include <boost/function.hpp>
6+
#include <boost/config.hpp>
7+
8+
#if defined(THROW_BAD_FUNCTION_CALL_DYN_LINK)
9+
# define EXPORT BOOST_SYMBOL_EXPORT
10+
#else
11+
# define EXPORT
12+
#endif
13+
14+
EXPORT void throw_bad_function_call()
15+
{
16+
throw boost::bad_function_call();
17+
}

0 commit comments

Comments
 (0)