]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/function/lazy_list_tests.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / phoenix / test / function / lazy_list_tests.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // lazy_list_tests.cpp
3 //
4 // tests on list<T>
5 //
6 ////////////////////////////////////////////////////////////////////////////
7 /*=============================================================================
8 Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
9 Copyright (c) 2001-2007 Joel de Guzman
10 Copyright (c) 2015 John Fletcher
11
12 Distributed under the Boost Software License, Version 1.0. (See accompanying
13 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
14 ==============================================================================*/
15
16 #include <boost/phoenix/core/limits.hpp>
17
18 #include <boost/detail/lightweight_test.hpp>
19 #include <boost/phoenix/core.hpp>
20 #include <boost/phoenix/function/lazy_prelude.hpp>
21
22
23 int main()
24 {
25 namespace phx = boost::phoenix;
26 using boost::phoenix::arg_names::arg1;
27 using boost::phoenix::arg_names::arg2;
28 using phx::null;
29 using phx::list;
30 using phx::head;
31 using phx::tail;
32 using phx::cons;
33 using phx::cat;
34 using phx::take;
35 using phx::NIL;
36
37 list<int> l0;
38 list<int> l1 = cons(1,l0);
39 list<int> l2 = cons(2,l1);
40 list<int> l3 = cons(3,l2);
41 list<int> l4 = cons(4,l3);
42 list<int> l5 = cons(5,NIL);
43 list<int> l6 = take(2,l4)();
44 list<int> l7 = cons(7,take(2,l4));
45 list<int> l8 = take(1,take(3,l4))();
46
47 BOOST_TEST(null(l0)());
48 BOOST_TEST(null(arg1)(l0));
49 BOOST_TEST(head(l1)() == 1);
50 BOOST_TEST(head(arg1)(l1) == 1);
51 BOOST_TEST(head(tail(l2))() == 1);
52 BOOST_TEST(head(tail(arg1))(l2) == 1);
53 BOOST_TEST(head(tail(tail(l3)))() == 1);
54 BOOST_TEST(head(tail(tail(arg1)))(l3) == 1);
55 BOOST_TEST(head(tail(tail(l4)))() == 2);
56 BOOST_TEST(head(tail(tail(arg1)))(l4) == 2);
57 BOOST_TEST(head(l5)() == 5);
58 BOOST_TEST(head(arg1)(l5) == 5);
59 BOOST_TEST(head(tail(l6))() == 3);
60 BOOST_TEST(head(tail(arg1))(l6) == 3);
61 BOOST_TEST(head(tail(l7))() == 4);
62 BOOST_TEST(head(tail(arg1))(l7) == 4);
63 BOOST_TEST(head(l8)() == 4);
64 BOOST_TEST(head(arg1)(l8) == 4);
65
66 list<int> l9 = cat(l8,take(2,l4));
67 list<int> l10 = cat(l8,NIL);
68 list<int> l11 = cat(l0,l7);
69 list<int> l12 = cat(l10,l8);
70
71 BOOST_TEST(head(tail(l9))() == 4);
72 BOOST_TEST(head(l10)() == 4);
73 BOOST_TEST(head(arg1)(l11) == 7);
74 BOOST_TEST(head(l12)() == 4);
75
76
77 return boost::report_errors();
78 }