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 push_front_actor, pop_front_actor
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include "action_tests.hpp"
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_erase_actor.hpp>
17 #include <map>
18
erase_action_test()19 void erase_action_test()
20 {
21 using namespace BOOST_SPIRIT_CLASSIC_NS;
22
23 const char* cp = "one,two,three";
24 const char* cp_first = cp;
25 const char* cp_last = cp + test_impl::string_length(cp);
26 const char* cp_i[] = {"one","two","three"};
27 typedef std::map<std::string, int> map_string_type;
28 map_string_type c;
29 map_string_type::const_iterator it_find;
30
31 scanner<char const*> scan(cp_first, cp_last);
32 match<> hit;
33
34 c["one"]=1;
35 c["two"]=2;
36 c["three"]=3;
37 c["four"]=4;
38
39 hit = (*((+alpha_p)[ erase_a(c) ] >> !ch_p(','))).parse(scan);
40
41 BOOST_CHECK(hit);
42 BOOST_CHECK_EQUAL(scan.first, scan.last);
43 BOOST_CHECK_EQUAL( c.size(), static_cast<map_string_type::size_type>(1));
44 for (int i=0;i<3;++i)
45 {
46 it_find = c.find(cp_i[i]);
47 BOOST_CHECK( it_find == c.end() );
48 }
49 scan.first = cp;
50
51 }
52
53
54
55