Ticket #3139: bind_typeof_test.cpp

File bind_typeof_test.cpp, 1.8 KB (added by v_gevorg@…, 13 years ago)

libs/bind/test/bind_typeof_test.cpp

Line 
1//
2// bind_typeof_test.cpp - test for bind/typeof.hpp
3//
4// Copyright (c) 2009 Gevorg Voskanyan
5//
6// Distributed under the Boost Software License, Version 1.0. (See
7// accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#define BOOST_TYPEOF_COMPLIANT
12
13#include <boost/bind.hpp>
14#include <boost/bind/typeof.hpp>
15
16#include <boost/type_traits/is_same.hpp>
17#include <boost/detail/lightweight_test.hpp>
18
19template < typename TestType, typename DeducedType >
20void test_against_deduced_type( DeducedType )
21{
22 BOOST_TEST(( boost::is_same< TestType, DeducedType >::value ));
23}
24
25#define TEST_AGAINST_DEDUCED_TYPE(Expr) test_against_deduced_type< BOOST_TYPEOF( Expr ) >( Expr )
26#define TYPEOF_TEST(Expr) TEST_AGAINST_DEDUCED_TYPE( Expr )
27
28void f0() {}
29void f1( int ) {}
30void f2( int, int ) {}
31void f3( int, int, int ) {}
32void f4( int, int, int, int ) {}
33void f5( int, int, int, int, int ) {}
34void f6( int, int, int, int, int, int ) {}
35void f7( int, int, int, int, int, int, int ) {}
36void f8( int, int, int, int, int, int, int, int ) {}
37void f9( int, int, int, int, int, int, int, int, int ) {}
38
39int main()
40{
41 TYPEOF_TEST( boost::bind( &f0 ) );
42 TYPEOF_TEST( boost::bind( &f1, _1 ) );
43 TYPEOF_TEST( boost::bind( &f2, _1, 0 ) );
44 TYPEOF_TEST( boost::bind( &f3, _1, 0, _2 ) );
45 TYPEOF_TEST( boost::bind( &f4, _1, 0, _2, 0 ) );
46 TYPEOF_TEST( boost::bind( &f5, _1, 0, _2, 0, _3 ) );
47 TYPEOF_TEST( boost::bind( &f6, _1, 0, _2, 0, _3, 0 ) );
48 TYPEOF_TEST( boost::bind( &f7, _1, 0, _2, 0, _3, 0, _4 ) );
49 TYPEOF_TEST( boost::bind( &f8, _1, 0, _2, 0, _3, 0, _4, 0 ) );
50 TYPEOF_TEST( boost::bind( &f9, _1, 0, _2, 0, _3, 0, _4, 0, _5 ) );
51 TYPEOF_TEST( boost::bind( &f9, _1, _2, _3, _4, _5, _6, _7, _8, _9 ) );
52 return boost::report_errors();
53}