Skip to content

Commit

Permalink
Add test_return_function
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Nov 13, 2018
1 parent b6b0568 commit 17716b6
Show file tree
Hide file tree
Showing 3 changed files with 53 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 @@ -57,3 +57,8 @@ local check14 = [ check-target-builds mixed_cxxstd/<cxxstd>14 : : <build>no ] ;

run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>14 : : : <link>shared $(check14) : mixed_cxxstd_shared_14 ;
run test_mixed_cxxstd.cpp mixed_cxxstd/<cxxstd>14 : : : <link>static $(check14) : mixed_cxxstd_static_14 ;

lib return_function : return_function.cpp : <link>shared:<define>RETURN_FUNCTION_DYN_LINK=1 ;

run test_return_function.cpp return_function : : : <link>shared : return_function_shared ;
run test_return_function.cpp return_function : : : <link>static : return_function_static ;
27 changes: 27 additions & 0 deletions test/return_function.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

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

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

#if defined(RETURN_FUNCTION_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif

int f( int x, int y )
{
return x + y;
}

EXPORT boost::function<int(int, int)> get_fn_1()
{
return f;
}

EXPORT boost::function2<int, int, int> get_fn_2()
{
return f;
}
21 changes: 21 additions & 0 deletions test/test_return_function.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

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

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

//

boost::function<int(int, int)> get_fn_1();
boost::function2<int, int, int> get_fn_2();

//

int main()
{
BOOST_TEST_EQ( get_fn_1()( 1, 2 ), 3 );
BOOST_TEST_EQ( get_fn_2()( 1, 2 ), 3 );

return boost::report_errors();
}

0 comments on commit 17716b6

Please sign in to comment.