• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 ////////////////////////////////////////////////////////////////////////////
2 // lazy_list3_tests.cpp
3 //
4 // more 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 
main()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 namespace phx;
29 
30     list<int> l    = enum_from(2);
31     list<int> ll   = take(4,l);
32     list<int> lll  = take(12,l);
33     list<int> l2   = enum_from_to(2,10);
34     list<int> ll2  = take(4,l2);
35     list<int> lll2 = take(12,l2);
36     list<int> evens = filter(even,l);
37     list<int> odds  = filter(odd,l);
38     list<int> even4 = take(4,evens)();
39     list<int> odd4  = take(4,odds)();
40     list<int> itersome = take(4,iterate(dec,1))();
41     list<int> repeatsome = take(4,repeat(1))();
42 
43     BOOST_TEST(last(ll)()   == 5);
44     BOOST_TEST(last(lll)()  == 13);
45     BOOST_TEST(last(ll2)()  == 5);
46     BOOST_TEST(last(lll2)() == 10);
47     BOOST_TEST(length(lll2)() == 9);
48     BOOST_TEST(at_(even4,3)() == 8);
49     BOOST_TEST(at_(odd4,2)()  == 7);
50     BOOST_TEST(at_(itersome,3)()   == -3);
51     BOOST_TEST(at_(repeatsome,3)() == 1);
52 
53     return boost::report_errors();
54 }
55