]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/actor/swap_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / classic / test / actor / swap_test.cpp
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 and_assign_actor
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include "action_tests.hpp"
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_swap_actor.hpp>
17
18 void swap_action_test()
19 {
20 using namespace BOOST_SPIRIT_CLASSIC_NS;
21
22 const char* cp = "63";
23 const char* cp_first = cp;
24 const char* cp_last = cp + test_impl::string_length(cp);
25 std::vector<int> v1,v2;
26
27 v1.push_back(0);
28 v1.push_back(1);
29
30 v2.push_back(2);
31 v2.push_back(3);
32
33 scanner<char const*> scan( cp_first, cp_last );
34 match<> hit;
35
36 hit = int_p[ swap_a(v1,v2)].parse(scan);
37 BOOST_CHECK(hit);
38 BOOST_CHECK_EQUAL(scan.first, scan.last);
39 BOOST_CHECK(v1.size()==2);
40 BOOST_CHECK(v2.size()==2);
41 BOOST_CHECK_EQUAL(v2[0],0);
42 BOOST_CHECK_EQUAL(v2[1],1);
43 BOOST_CHECK_EQUAL(v1[0],2);
44 BOOST_CHECK_EQUAL(v1[1],3);
45 }
46
47