]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/actor/push_back_test.cpp
1 /*=============================================================================
2 Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3 http://spirit.sourceforge.net/
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 =============================================================================*/
10 ///////////////////////////////////////////////////////////////////////////////
11 // Test suite for push_back_actor
12 ///////////////////////////////////////////////////////////////////////////////
14 #include "action_tests.hpp"
20 #include <boost/spirit/include/classic_core.hpp>
22 #include <boost/bind.hpp>
23 #include <boost/spirit/include/classic_push_back_actor.hpp>
24 #include <boost/spirit/include/classic_lists.hpp>
26 template<typename ContainerT
>
29 using namespace BOOST_SPIRIT_CLASSIC_NS
;
31 const char* cp
= "one,two,three";
32 const char* cp_first
= cp
;
33 const char* cp_last
= cp
+ test_impl::string_length(cp
);
34 const char* cp_i
[] = {"one","two","three"};
37 typename
ContainerT::const_iterator it
;
39 scanner
<char const*> scan( cp_first
, cp_last
);
42 hit
= list_p( (*alpha_p
)[ push_back_a(c
)] , ch_p(',') ).parse(scan
);
44 BOOST_CHECK_EQUAL(scan
.first
, scan
.last
);
45 BOOST_CHECK_EQUAL( c
.size(), static_cast<typename
ContainerT::size_type
>(3));
46 for (i
=0, it
= c
.begin();i
<3 && it
!= c
.end();++i
, ++it
)
47 BOOST_CHECK_EQUAL( cp_i
[i
], *it
);
51 void push_back_action_test()
53 push_back_test
< std::deque
<std::string
> >();
54 push_back_test
< std::vector
<std::string
> >();