increment_test.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*=============================================================================
  2. Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
  3. http://spirit.sourceforge.net/
  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. ///////////////////////////////////////////////////////////////////////////////
  9. // Test suite for increment_actor
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "action_tests.hpp"
  12. #include <boost/spirit/include/classic_core.hpp>
  13. #include <boost/spirit/include/classic_increment_actor.hpp>
  14. void increment_action_test()
  15. {
  16. using namespace BOOST_SPIRIT_CLASSIC_NS;
  17. BOOST_MESSAGE("increment_test");
  18. const char* cp = "63";
  19. const char* cp_first = cp;
  20. const char* cp_last = cp + test_impl::string_length(cp);
  21. int h=127;
  22. int hm=h;
  23. scanner<char const*> scan( cp_first, cp_last );
  24. match<> hit;
  25. hit = int_p[ increment_a(hm)].parse(scan);
  26. BOOST_CHECK(hit);
  27. BOOST_CHECK_EQUAL(scan.first, scan.last);
  28. ++h;
  29. BOOST_CHECK_EQUAL( hm,h);
  30. }