From 17716b63f2a27d7b2bf0a170da31fa5079a495ec Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 14 Nov 2018 00:11:27 +0200 Subject: [PATCH] Add test_return_function --- test/Jamfile.v2 | 5 +++++ test/return_function.cpp | 27 +++++++++++++++++++++++++++ test/test_return_function.cpp | 21 +++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 test/return_function.cpp create mode 100644 test/test_return_function.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6bd1d69..393691d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -57,3 +57,8 @@ local check14 = [ check-target-builds mixed_cxxstd/14 : : no ] ; run test_mixed_cxxstd.cpp mixed_cxxstd/14 : : : shared $(check14) : mixed_cxxstd_shared_14 ; run test_mixed_cxxstd.cpp mixed_cxxstd/14 : : : static $(check14) : mixed_cxxstd_static_14 ; + +lib return_function : return_function.cpp : shared:RETURN_FUNCTION_DYN_LINK=1 ; + +run test_return_function.cpp return_function : : : shared : return_function_shared ; +run test_return_function.cpp return_function : : : static : return_function_static ; diff --git a/test/return_function.cpp b/test/return_function.cpp new file mode 100644 index 0000000..3fca7bb --- /dev/null +++ b/test/return_function.cpp @@ -0,0 +1,27 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +#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 get_fn_1() +{ + return f; +} + +EXPORT boost::function2 get_fn_2() +{ + return f; +} diff --git a/test/test_return_function.cpp b/test/test_return_function.cpp new file mode 100644 index 0000000..05712ed --- /dev/null +++ b/test/test_return_function.cpp @@ -0,0 +1,21 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +// + +boost::function get_fn_1(); +boost::function2 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(); +}