mixed_binary_tests.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*=============================================================================
  2. Phoenix V1.2.1
  3. Copyright (c) 2001-2003 Joel de Guzman
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #include <iostream>
  9. #include <string>
  10. #include <boost/detail/lightweight_test.hpp>
  11. #define PHOENIX_LIMIT 15
  12. #include <boost/spirit/include/phoenix1_primitives.hpp>
  13. #include <boost/spirit/include/phoenix1_operators.hpp>
  14. using namespace phoenix;
  15. using namespace std;
  16. ///////////////////////////////////////////////////////////////////////////////
  17. int
  18. main()
  19. {
  20. int i1 = 1, i2 = 2, i50 = 50, i100 = 100;
  21. double d2_5 = 2.5;
  22. string hello = "hello";
  23. const char* world = " world";
  24. ///////////////////////////////////////////////////////////////////////////////
  25. //
  26. // Mixed type operators
  27. //
  28. ///////////////////////////////////////////////////////////////////////////////
  29. BOOST_TEST((arg1 + arg2)(i100, i50) == (i100 + i50));
  30. BOOST_TEST((arg1 + 3)(i100) == (3 + i100));
  31. BOOST_TEST((arg1 + arg2)(hello, world) == "hello world");
  32. BOOST_TEST((arg1 + arg2)(i1, d2_5) == (i1 + d2_5));
  33. BOOST_TEST((*(arg1 + arg2))(world, i2) == *(world + i2));
  34. BOOST_TEST((*(arg1 + arg2))(i2, world) == *(i2 + world));
  35. BOOST_TEST((*(val(world+i2) - arg1))(i2) == *world);
  36. ///////////////////////////////////////////////////////////////////////////////
  37. //
  38. // End asserts
  39. //
  40. ///////////////////////////////////////////////////////////////////////////////
  41. return boost::report_errors();
  42. }