clear_test.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 clear_actor
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "action_tests.hpp"
  12. #include <boost/spirit/include/classic_core.hpp>
  13. #include <vector>
  14. #include <boost/spirit/include/classic_clear_actor.hpp>
  15. void clear_action_test()
  16. {
  17. using namespace BOOST_SPIRIT_CLASSIC_NS;
  18. BOOST_MESSAGE("clear_test");
  19. const char* cp = "63";
  20. const char* cp_first = cp;
  21. const char* cp_last = cp + test_impl::string_length(cp);
  22. std::vector<int> c;
  23. c.push_back(1);
  24. scanner<char const*> scan( cp_first, cp_last );
  25. match<> hit;
  26. hit = int_p[ clear_a(c)].parse(scan);
  27. BOOST_CHECK(hit);
  28. BOOST_CHECK_EQUAL(scan.first, scan.last);
  29. BOOST_CHECK( c.empty() );
  30. scan.first = cp;
  31. c.push_back(1);
  32. hit = str_p("63")[ clear_a(c)].parse(scan);
  33. BOOST_CHECK(hit);
  34. BOOST_CHECK_EQUAL(scan.first, scan.last);
  35. BOOST_CHECK( c.empty() );
  36. }