]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/bind_and_or_test.cpp
1 #include <boost/config.hpp>
3 #if defined(BOOST_MSVC)
4 #pragma warning(disable: 4786) // identifier truncated in debug info
5 #pragma warning(disable: 4710) // function not inlined
6 #pragma warning(disable: 4711) // function selected for automatic inline expansion
7 #pragma warning(disable: 4514) // unreferenced inline removed
11 // bind_and_or_test.cpp - &&, || operators
13 // Copyright (c) 2008 Peter Dimov
15 // Distributed under the Boost Software License, Version 1.0. (See
16 // accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
20 #include <boost/bind/bind.hpp>
21 #include <boost/core/lightweight_test.hpp>
23 using namespace boost::placeholders
;
39 BOOST_ERROR( "Short-circuit evaluation failure" );
43 template< class F
, class A1
, class A2
, class R
> void test( F f
, A1 a1
, A2 a2
, R r
)
45 BOOST_TEST( f( a1
, a2
) == r
);
52 test( boost::bind( f
, true ) && boost::bind( g
, true ), false, false, f( true ) && g( true ) );
53 test( boost::bind( f
, true ) && boost::bind( g
, false ), false, false, f( true ) && g( false ) );
55 test( boost::bind( f
, false ) && boost::bind( h
), false, false, f( false ) && h() );
57 test( boost::bind( f
, _1
) && boost::bind( g
, _2
), true, true, f( true ) && g( true ) );
58 test( boost::bind( f
, _1
) && boost::bind( g
, _2
), true, false, f( true ) && g( false ) );
60 test( boost::bind( f
, _1
) && boost::bind( h
), false, false, f( false ) && h() );
64 test( boost::bind( f
, false ) || boost::bind( g
, true ), false, false, f( false ) || g( true ) );
65 test( boost::bind( f
, false ) || boost::bind( g
, false ), false, false, f( false ) || g( false ) );
67 test( boost::bind( f
, true ) || boost::bind( h
), false, false, f( true ) || h() );
69 test( boost::bind( f
, _1
) || boost::bind( g
, _2
), false, true, f( false ) || g( true ) );
70 test( boost::bind( f
, _1
) || boost::bind( g
, _2
), false, false, f( false ) || g( false ) );
72 test( boost::bind( f
, _1
) || boost::bind( h
), true, false, f( true ) || h() );
76 return boost::report_errors();