From 6961c50cceed9582fafda48dcaba4c1aee846218 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 12 Feb 2023 03:23:54 +0200 Subject: [PATCH] Add fn_eq_bind_test. Refs #45. --- test/Jamfile.v2 | 2 + test/fn_eq_bind_test.cpp | 87 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 test/fn_eq_bind_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 423f61c..168fb7f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -84,3 +84,5 @@ run test_return_function.cpp return_function/14 : : : static $(che run quick.cpp ; compile issue_42.cpp ; + +run fn_eq_bind_test.cpp ; diff --git a/test/fn_eq_bind_test.cpp b/test/fn_eq_bind_test.cpp new file mode 100644 index 0000000..b6ad599 --- /dev/null +++ b/test/fn_eq_bind_test.cpp @@ -0,0 +1,87 @@ +// Copyright 2023 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +using namespace boost::placeholders; + +int f1() { return 1; } +int f2() { return 2; } + +int main() +{ + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + { + boost::function fn( boost::bind( f1 ) ); + + BOOST_TEST( fn == boost::bind( f1 ) ); + BOOST_TEST( fn != boost::bind( f2 ) ); + } + + return boost::report_errors(); +}