• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3     http://spirit.sourceforge.net/
4 
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 
10 ///////////////////////////////////////////////////////////////////////////////
11 // Test suite for clear_actor
12 ///////////////////////////////////////////////////////////////////////////////
13 
14 #include "action_tests.hpp"
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <vector>
17 #include <boost/spirit/include/classic_clear_actor.hpp>
18 
clear_action_test()19 void clear_action_test()
20 {
21     using namespace BOOST_SPIRIT_CLASSIC_NS;
22 
23     BOOST_MESSAGE("clear_test");
24 
25     const char* cp = "63";
26     const char* cp_first = cp;
27     const char* cp_last = cp + test_impl::string_length(cp);
28     std::vector<int> c;
29     c.push_back(1);
30 
31     scanner<char const*> scan( cp_first, cp_last );
32     match<> hit;
33 
34     hit = int_p[ clear_a(c)].parse(scan);
35     BOOST_CHECK(hit);
36     BOOST_CHECK_EQUAL(scan.first, scan.last);
37     BOOST_CHECK( c.empty() );
38     scan.first = cp;
39     c.push_back(1);
40 
41     hit = str_p("63")[ clear_a(c)].parse(scan);
42     BOOST_CHECK(hit);
43     BOOST_CHECK_EQUAL(scan.first, scan.last);
44     BOOST_CHECK( c.empty() );
45 }
46 
47 
48