1 /*
2 Copyright 2007 Tobias Schwinger
3
4 Copyright 2019 Glen Joseph Fernandes
5 (glenjofe@gmail.com)
6
7 Distributed under the Boost Software License, Version 1.0.
8 (http://www.boost.org/LICENSE_1_0.txt)
9 */
10 #include <boost/functional/value_factory.hpp>
11 #include <boost/core/lightweight_test.hpp>
12
13 class sum {
14 public:
sum(int i0=0,int i1=0,int i2=0,int i3=0,int i4=0,int i5=0,int i6=0,int i7=0,int i8=0,int i9=0)15 explicit sum(int i0 = 0, int i1 = 0, int i2 = 0, int i3 = 0,
16 int i4 = 0, int i5 = 0, int i6 = 0, int i7 = 0,
17 int i8 = 0, int i9 = 0)
18 : value_(i0 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9) { }
19
get() const20 int get() const {
21 return value_;
22 }
23
24 private:
25 int value_;
26 };
27
main()28 int main()
29 {
30 boost::value_factory<sum> x;
31 int a = 1;
32 int b = 2;
33 int c = 3;
34 int d = 4;
35 int e = 5;
36 int f = 6;
37 int g = 7;
38 int h = 8;
39 int i = 9;
40 int j = 10;
41 {
42 sum s(x());
43 BOOST_TEST(s.get() == 0);
44 }
45 {
46 sum s(x(a));
47 BOOST_TEST(s.get() == 1);
48 }
49 {
50 sum s(x(a, b));
51 BOOST_TEST(s.get() == 3);
52 }
53 {
54 sum s(x(a, b, c));
55 BOOST_TEST(s.get() == 6);
56 }
57 {
58 sum s(x(a, b, c, d));
59 BOOST_TEST(s.get() == 10);
60 }
61 {
62 sum s(x(a, b, c, d, e));
63 BOOST_TEST(s.get() == 15);
64 }
65 {
66 sum s(x(a, b, c, d, e, f));
67 BOOST_TEST(s.get() == 21);
68 }
69 {
70 sum s(x(a, b, c, d, e, f, g));
71 BOOST_TEST(s.get() == 28);
72 }
73 {
74 sum s(x(a, b, c, d, e, f, g, h));
75 BOOST_TEST(s.get() == 36);
76 }
77 {
78 sum s(x(a, b, c, d, e, f, g, h, i));
79 BOOST_TEST(s.get() == 45);
80 }
81 {
82 sum s(x(a, b, c, d, e, f, g, h, i, j));
83 BOOST_TEST(s.get() == 55);
84 }
85 return boost::report_errors();
86 }
87