diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c9a4473..c944bbd 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -74,3 +74,4 @@ run bind_noexcept_test.cpp ; run bind_noexcept_mf_test.cpp ; run global_placeholders.cpp ; run mem_fn_noexcept_test.cpp ; +run bind_cpp20_test.cpp ; diff --git a/test/bind_cpp20_test.cpp b/test/bind_cpp20_test.cpp new file mode 100644 index 0000000..021cbcb --- /dev/null +++ b/test/bind_cpp20_test.cpp @@ -0,0 +1,37 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +// + +int main() +{ + BOOST_TEST_EQ( boost::bind( std::plus(), 1, 2 )(), 3 ); + BOOST_TEST_EQ( boost::bind( std::minus(), 1, 2 )(), -1 ); + BOOST_TEST_EQ( boost::bind( std::multiplies(), 1, 2 )(), 2 ); + BOOST_TEST_EQ( boost::bind( std::divides(), 1, 2 )(), 0 ); + BOOST_TEST_EQ( boost::bind( std::modulus(), 1, 2 )(), 1 ); + BOOST_TEST_EQ( boost::bind( std::negate(), 1 )(), -1 ); + + BOOST_TEST_EQ( boost::bind( std::equal_to(), 1, 2 )(), false ); + BOOST_TEST_EQ( boost::bind( std::not_equal_to(), 1, 2 )(), true ); + BOOST_TEST_EQ( boost::bind( std::greater(), 1, 2 )(), false ); + BOOST_TEST_EQ( boost::bind( std::less(), 1, 2 )(), true ); + BOOST_TEST_EQ( boost::bind( std::greater_equal(), 1, 2 )(), false ); + BOOST_TEST_EQ( boost::bind( std::less_equal(), 1, 2 )(), true ); + + BOOST_TEST_EQ( boost::bind( std::logical_and(), 1, 2 )(), true ); + BOOST_TEST_EQ( boost::bind( std::logical_or(), 1, 2 )(), true ); + BOOST_TEST_EQ( boost::bind( std::logical_not(), 1 )(), false ); + + BOOST_TEST_EQ( boost::bind( std::bit_and(), 1, 2 )(), 0 ); + BOOST_TEST_EQ( boost::bind( std::bit_or(), 1, 2 )(), 3 ); + BOOST_TEST_EQ( boost::bind( std::bit_xor(), 1, 2 )(), 3 ); + BOOST_TEST_EQ( boost::bind( std::bit_not(), 1 )(), ~1 ); + + return boost::report_errors(); +}