From ee25007a9f3b418776bf2c1488325391248db69a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 6 Mar 2021 18:38:14 +0200 Subject: [PATCH] Add apply_test.cpp --- test/Jamfile.v2 | 1 + test/apply_test.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/apply_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2cf8583..c363f38 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -79,3 +79,4 @@ run protect_test2.cpp ; run protect_cpp20_test.cpp ; run bind_noexcept_mf2_test.cpp ; run std_placeholders_test.cpp ; +run apply_test.cpp ; diff --git a/test/apply_test.cpp b/test/apply_test.cpp new file mode 100644 index 0000000..24bcdf7 --- /dev/null +++ b/test/apply_test.cpp @@ -0,0 +1,29 @@ +// Copyright 2021 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include + +using namespace boost::placeholders; + +int f( int x ) +{ + return x; +} + +int main() +{ + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _1 ) ), 1 )(), 1 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _2 ) ), 1, 2 )(), 2 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _3 ) ), 1, 2, 3 )(), 3 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _4 ) ), 1, 2, 3, 4 )(), 4 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _5 ) ), 1, 2, 3, 4, 5 )(), 5 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _6 ) ), 1, 2, 3, 4, 5, 6 )(), 6 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _7 ) ), 1, 2, 3, 4, 5, 6, 7 )(), 7 ); + BOOST_TEST_EQ( boost::bind( boost::apply(), boost::protect( boost::bind( f, _8 ) ), 1, 2, 3, 4, 5, 6, 7, 8 )(), 8 ); + + return boost::report_errors(); +}