File: bind_no_placeholders_test.cpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (99 lines) | stat: -rw-r--r-- 2,509 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
//  bind_no_placeholders_test.cpp - test for BOOST_BIND_NO_PLACEHOLDERS
//
//  Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
//  Copyright (c) 2001 David Abrahams
//  Copyright (c) 2015 Peter Dimov
//
//  Distributed under the Boost Software License, Version 1.0.
//  See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt
//

#define BOOST_BIND_NO_PLACEHOLDERS
#include <boost/bind.hpp>
#include <boost/core/lightweight_test.hpp>

//

long f_0()
{
    return 17041L;
}

long f_1(long a)
{
    return a;
}

long f_2(long a, long b)
{
    return a + 10 * b;
}

long f_3(long a, long b, long c)
{
    return a + 10 * b + 100 * c;
}

long f_4(long a, long b, long c, long d)
{
    return a + 10 * b + 100 * c + 1000 * d;
}

long f_5(long a, long b, long c, long d, long e)
{
    return a + 10 * b + 100 * c + 1000 * d + 10000 * e;
}

long f_6(long a, long b, long c, long d, long e, long f)
{
    return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
}

long f_7(long a, long b, long c, long d, long e, long f, long g)
{
    return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
}

long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
{
    return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
}

long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
{
    return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
}

void function_test()
{
    using namespace boost;

    arg<1> _1;
    arg<2> _2;
    arg<3> _3;
    arg<4> _4;
    arg<5> _5;
    arg<6> _6;
    arg<7> _7;
    arg<8> _8;
    arg<9> _9;

    BOOST_TEST( bind(f_0)() == 17041L );
    BOOST_TEST( bind(f_1, _1)(1) == 1L );
    BOOST_TEST( bind(f_2, _1, _2)(1, 2) == 21L );
    BOOST_TEST( bind(f_3, _1, _2, _3)(1, 2, 3) == 321L );
    BOOST_TEST( bind(f_4, _1, _2, _3, _4)(1, 2, 3, 4) == 4321L );
    BOOST_TEST( bind(f_5, _1, _2, _3, _4, _5)(1, 2, 3, 4, 5) == 54321L );
    BOOST_TEST( bind(f_6, _1, _2, _3, _4, _5, _6)(1, 2, 3, 4, 5, 6) == 654321L );
    BOOST_TEST( bind(f_7, _1, _2, _3, _4, _5, _6, _7)(1, 2, 3, 4, 5, 6, 7) == 7654321L );
    BOOST_TEST( bind(f_8, _1, _2, _3, _4, _5, _6, _7, _8)(1, 2, 3, 4, 5, 6, 7, 8) == 87654321L );
    BOOST_TEST( bind(f_9, _1, _2, _3, _4, _5, _6, _7, _8, _9)(1, 2, 3, 4, 5, 6, 7, 8, 9) == 987654321L );
}

int main()
{
    function_test();
    return boost::report_errors();
}