Skip to content

Commit

Permalink
Add throw/catch test for bad_function_call
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov authored and jeking3 committed Oct 26, 2018
1 parent 755d3c2 commit 5b2acbc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -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 : <link>shared:<define>THROW_BAD_FUNCTION_CALL_DYN_LINK=1 ;

run test_bad_function_call.cpp throw_bad_function_call : : : <link>shared : test_bad_function_call_shared ;
run test_bad_function_call.cpp throw_bad_function_call : : : <link>static : test_bad_function_call_static ;
14 changes: 14 additions & 0 deletions test/test_bad_function_call.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.

#include <boost/function.hpp>
#include <boost/core/lightweight_test.hpp>

void throw_bad_function_call();

int main()
{
BOOST_TEST_THROWS( throw_bad_function_call(), boost::bad_function_call );
return boost::report_errors();
}
17 changes: 17 additions & 0 deletions test/throw_bad_function_call.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.

#include <boost/function.hpp>
#include <boost/config.hpp>

#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();
}

0 comments on commit 5b2acbc

Please sign in to comment.