2 Copyright 2007 Tobias Schwinger
4 Copyright 2019 Glen Joseph Fernandes
7 Distributed under the Boost Software License, Version 1.0.
8 (http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/functional/factory.hpp>
11 #include <boost/core/lightweight_test.hpp>
12 #include <boost/smart_ptr/scoped_ptr.hpp>
16 explicit sum(int i0 = 0, int i1 = 0, int i2 = 0, int i3 = 0,
17 int i4 = 0, int i5 = 0, int i6 = 0, int i7 = 0,
18 int i8 = 0, int i9 = 0)
19 : value_(i0 + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9) { }
31 boost::factory<sum*> x;
43 boost::scoped_ptr<sum> s(x());
44 BOOST_TEST(s->get() == 0);
47 boost::scoped_ptr<sum> s(x(a));
48 BOOST_TEST(s->get() == 1);
51 boost::scoped_ptr<sum> s(x(a, b));
52 BOOST_TEST(s->get() == 3);
55 boost::scoped_ptr<sum> s(x(a, b, c));
56 BOOST_TEST(s->get() == 6);
59 boost::scoped_ptr<sum> s(x(a, b, c, d));
60 BOOST_TEST(s->get() == 10);
63 boost::scoped_ptr<sum> s(x(a, b, c, d, e));
64 BOOST_TEST(s->get() == 15);
67 boost::scoped_ptr<sum> s(x(a, b, c, d, e, f));
68 BOOST_TEST(s->get() == 21);
71 boost::scoped_ptr<sum> s(x(a, b, c, d, e, f, g));
72 BOOST_TEST(s->get() == 28);
75 boost::scoped_ptr<sum> s(x(a, b, c, d, e, f, g, h));
76 BOOST_TEST(s->get() == 36);
79 boost::scoped_ptr<sum> s(x(a, b, c, d, e, f, g, h, i));
80 BOOST_TEST(s->get() == 45);
83 boost::scoped_ptr<sum> s(x(a, b, c, d, e, f, g, h, i, j));
84 BOOST_TEST(s->get() == 55);
86 return boost::report_errors();