From c18d12313753b6c03bcd2d91233f9ae6f47af143 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Nov 2018 17:54:17 +0200 Subject: [PATCH] Add test_mixed_cxxstd --- test/Jamfile.v2 | 16 +++++++++++++ test/mixed_cxxstd.cpp | 42 +++++++++++++++++++++++++++++++++ test/test_mixed_cxxstd.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 test/mixed_cxxstd.cpp create mode 100644 test/test_mixed_cxxstd.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7f5d297..b19bfcf 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -41,3 +41,19 @@ lib throw_bad_function_call : throw_bad_function_call.cpp : shared:shared : test_bad_function_call_shared ; run test_bad_function_call.cpp throw_bad_function_call : : : static : test_bad_function_call_static ; + +lib mixed_cxxstd : mixed_cxxstd.cpp : shared:MIXED_CXXSTD_DYN_LINK=1 ; + +run test_mixed_cxxstd.cpp mixed_cxxstd : : : shared : mixed_cxxstd_shared ; +run test_mixed_cxxstd.cpp mixed_cxxstd : : : static : mixed_cxxstd_static ; + +run test_mixed_cxxstd.cpp mixed_cxxstd/98 : : : shared : mixed_cxxstd_shared_98 ; +run test_mixed_cxxstd.cpp mixed_cxxstd/98 : : : static : mixed_cxxstd_static_98 ; + +run test_mixed_cxxstd.cpp mixed_cxxstd/0x : : : shared : mixed_cxxstd_shared_0x ; +run test_mixed_cxxstd.cpp mixed_cxxstd/0x : : : static : mixed_cxxstd_static_0x ; + +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 ; diff --git a/test/mixed_cxxstd.cpp b/test/mixed_cxxstd.cpp new file mode 100644 index 0000000..417037a --- /dev/null +++ b/test/mixed_cxxstd.cpp @@ -0,0 +1,42 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +#if defined(MIXED_CXXSTD_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +EXPORT void call_fn_1( boost::function const & fn ) +{ + fn(); +} + +EXPORT void call_fn_2( boost::function const & fn ) +{ + fn( 1 ); +} + +EXPORT void call_fn_3( boost::function const & fn ) +{ + fn( 1, 2 ); +} + +EXPORT void call_fn_4( boost::function0 const & fn ) +{ + fn(); +} + +EXPORT void call_fn_5( boost::function1 const & fn ) +{ + fn( 1 ); +} + +EXPORT void call_fn_6( boost::function2 const & fn ) +{ + fn( 1, 2 ); +} diff --git a/test/test_mixed_cxxstd.cpp b/test/test_mixed_cxxstd.cpp new file mode 100644 index 0000000..6622ab3 --- /dev/null +++ b/test/test_mixed_cxxstd.cpp @@ -0,0 +1,48 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include +#include + +// + +void call_fn_1( boost::function const & fn ); +void call_fn_2( boost::function const & fn ); +void call_fn_3( boost::function const & fn ); + +void call_fn_4( boost::function0 const & fn ); +void call_fn_5( boost::function1 const & fn ); +void call_fn_6( boost::function2 const & fn ); + +// + +static int v; + +void f0() +{ + v = -1; +} + +void f1( int x ) +{ + v = x; +} + +void f2( int x, int y ) +{ + v = x + y; +} + +int main() +{ + v = 0; call_fn_1( f0 ); BOOST_TEST_EQ( v, -1 ); + v = 0; call_fn_2( f1 ); BOOST_TEST_EQ( v, 1 ); + v = 0; call_fn_3( f2 ); BOOST_TEST_EQ( v, 3 ); + + v = 0; call_fn_4( f0 ); BOOST_TEST_EQ( v, -1 ); + v = 0; call_fn_5( f1 ); BOOST_TEST_EQ( v, 1 ); + v = 0; call_fn_6( f2 ); BOOST_TEST_EQ( v, 3 ); + + return boost::report_errors(); +}