lazy_operator_tests.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ////////////////////////////////////////////////////////////////////////////
  2. // lazy_operator_tests.cpp
  3. //
  4. // lazy operator tests
  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_operator.hpp>
  18. int main()
  19. {
  20. using boost::phoenix::plus;
  21. using boost::phoenix::minus;
  22. using boost::phoenix::arg_names::arg1;
  23. using boost::phoenix::arg_names::arg2;
  24. int a = 123;
  25. int b = 256;
  26. BOOST_TEST(plus(arg1, arg2)(a, b) == a+b);
  27. BOOST_TEST(plus(arg1, arg2, 3)(a, b) == a+b+3);
  28. BOOST_TEST(plus(arg1, b)(a) == a+b);
  29. BOOST_TEST(plus(a, arg2)(a,b) == a+b);
  30. BOOST_TEST(plus(a, arg1)(b) == a+b);
  31. BOOST_TEST(plus(a, b)() == a+b);
  32. BOOST_TEST(minus(a, b)() == a-b);
  33. BOOST_TEST(plus(minus(a, b),b)() == a);
  34. BOOST_TEST(plus(minus(arg1, b),b)(a) == a);
  35. BOOST_TEST(plus(minus(arg1, arg2),b)(a,b) == a);
  36. BOOST_TEST(plus(minus(arg1, arg2),arg2)(a,b) ==a);
  37. return boost::report_errors();
  38. }