]>
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/spirit/include/classic_push_back_actor.hpp>
23 #include <boost/spirit/include/classic_lists.hpp>
25 template<typename ContainerT
>
28 using namespace BOOST_SPIRIT_CLASSIC_NS
;
30 const char* cp
= "one,two,three";
31 const char* cp_first
= cp
;
32 const char* cp_last
= cp
+ test_impl::string_length(cp
);
33 const char* cp_i
[] = {"one","two","three"};
36 typename
ContainerT::const_iterator it
;
38 scanner
<char const*> scan( cp_first
, cp_last
);
41 hit
= list_p( (*alpha_p
)[ push_back_a(c
)] , ch_p(',') ).parse(scan
);
43 BOOST_CHECK_EQUAL(scan
.first
, scan
.last
);
44 BOOST_CHECK_EQUAL( c
.size(), static_cast<typename
ContainerT::size_type
>(3));
45 for (i
=0, it
= c
.begin();i
<3 && it
!= c
.end();++i
, ++it
)
46 BOOST_CHECK_EQUAL( cp_i
[i
], *it
);
50 void push_back_action_test()
52 push_back_test
< std::deque
<std::string
> >();
53 push_back_test
< std::vector
<std::string
> >();