new_test.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=============================================================================
  2. Phoenix V1.2.1
  3. Copyright (c) 2001-2003 Joel de Guzman
  4. Copyright (c) 2003 Vaclav Vesely
  5. Use, modification and distribution is subject to the Boost Software
  6. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. http://www.boost.org/LICENSE_1_0.txt)
  8. ==============================================================================*/
  9. #include <iostream>
  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_new.hpp>
  14. using namespace phoenix;
  15. using namespace std;
  16. class X
  17. {
  18. public:
  19. X(int i_ = 1)
  20. : i(i_)
  21. {}
  22. int i;
  23. };
  24. ///////////////////////////////////////////////////////////////////////////////
  25. int
  26. main()
  27. {
  28. int i2 = 2;
  29. X x3(3);
  30. BOOST_TEST(new_<int>()() != NULL);
  31. BOOST_TEST(*new_<int>(arg1)(i2) == 2);
  32. BOOST_TEST(new_<X>()() != NULL);
  33. BOOST_TEST(new_<X>()()->i == 1);
  34. BOOST_TEST(new_<X>(arg1)(i2)->i == 2);
  35. BOOST_TEST(new_<X>(arg1)(x3)->i == 3);
  36. return boost::report_errors();
  37. }