lazy_thunk_tests.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //////////////////////////////////////////////////////////////////
  2. //
  3. // lazy_thunk_tests.cpp
  4. //
  5. // Tests for thunk functions.
  6. //
  7. //
  8. /*=============================================================================
  9. Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
  10. Copyright (c) 2001-2007 Joel de Guzman
  11. Copyright (c) 2015 John Fletcher
  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. #include <iostream>
  16. #include <boost/phoenix/core.hpp>
  17. #include <boost/phoenix/function.hpp>
  18. #include <boost/shared_ptr.hpp>
  19. #include <boost/phoenix/function/lazy_prelude.hpp>
  20. #include <boost/detail/lightweight_test.hpp>
  21. using namespace boost::phoenix;
  22. using std::cout;
  23. using std::endl;
  24. int main() {
  25. using boost::phoenix::arg_names::arg1;
  26. using boost::phoenix::arg_names::arg2;
  27. BOOST_TEST( thunk1(inc,1)()() == 2);
  28. BOOST_TEST( thunk1(inc,arg1)(1)() == 2);
  29. BOOST_TEST( thunk2(plus,1,2)()() == 3);
  30. BOOST_TEST( thunk2(plus,arg1,arg2)(1,2)() == 3);
  31. list<int> l = enum_from_to(1,5);
  32. list<int> l4 = take(4,l)();
  33. BOOST_TEST( foldl(plus,0,l4)() == 10);
  34. BOOST_TEST( thunk3(foldl,plus,0,l4)()() == 10);
  35. BOOST_TEST( thunk3(foldl,plus,arg1,l4)(0)() == 10);
  36. return boost::report_errors();
  37. }