lazy_list3_tests.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. Distributed under the Boost Software License, Version 1.0. (See accompanying
  12. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  13. ==============================================================================*/
  14. #include <boost/phoenix/core/limits.hpp>
  15. #include <boost/detail/lightweight_test.hpp>
  16. #include <boost/phoenix/core.hpp>
  17. #include <boost/phoenix/function/lazy_prelude.hpp>
  18. int main()
  19. {
  20. namespace phx = boost::phoenix;
  21. //using boost::phoenix::arg_names::arg1;
  22. //using boost::phoenix::arg_names::arg2;
  23. using namespace phx;
  24. list<int> l = enum_from(2);
  25. list<int> ll = take(4,l);
  26. list<int> lll = take(12,l);
  27. list<int> l2 = enum_from_to(2,10);
  28. list<int> ll2 = take(4,l2);
  29. list<int> lll2 = take(12,l2);
  30. list<int> evens = filter(even,l);
  31. list<int> odds = filter(odd,l);
  32. list<int> even4 = take(4,evens)();
  33. list<int> odd4 = take(4,odds)();
  34. list<int> itersome = take(4,iterate(dec,1))();
  35. list<int> repeatsome = take(4,repeat(1))();
  36. BOOST_TEST(last(ll)() == 5);
  37. BOOST_TEST(last(lll)() == 13);
  38. BOOST_TEST(last(ll2)() == 5);
  39. BOOST_TEST(last(lll2)() == 10);
  40. BOOST_TEST(length(lll2)() == 9);
  41. BOOST_TEST(at_(even4,3)() == 8);
  42. BOOST_TEST(at_(odd4,2)() == 7);
  43. BOOST_TEST(at_(itersome,3)() == -3);
  44. BOOST_TEST(at_(repeatsome,3)() == 1);
  45. return boost::report_errors();
  46. }