]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/seek.cpp
1 /*//////////////////////////////////////////////////////////////////////////////
2 Copyright (c) 2011 Jamboree
3 Copyright (c) 2014 Lee Clagett
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //////////////////////////////////////////////////////////////////////////////*/
10 #include <boost/spirit/home/x3/auxiliary/eoi.hpp>
11 #include <boost/spirit/home/x3/core.hpp>
12 #include <boost/spirit/home/x3/char.hpp>
13 #include <boost/spirit/home/x3/string.hpp>
14 #include <boost/spirit/home/x3/numeric.hpp>
15 #include <boost/spirit/home/x3/operator/plus.hpp>
16 #include <boost/spirit/home/x3/operator/sequence.hpp>
18 #include <boost/spirit/home/x3/directive/seek.hpp>
23 ///////////////////////////////////////////////////////////////////////////////
26 using namespace spirit_test
;
27 namespace x3
= boost::spirit::x3
;
29 BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(x3::seek
['x']);
33 BOOST_TEST(test("", x3::seek
[x3::eoi
]));
34 BOOST_TEST(test(" ", x3::seek
[x3::eoi
], x3::space
));
35 BOOST_TEST(test("a", x3::seek
[x3::eoi
]));
36 BOOST_TEST(test(" a", x3::seek
[x3::eoi
], x3::space
));
39 // test literal finding
44 test_attr("!@#$%^&*KEY:123", x3::seek
["KEY:"] >> x3::int_
, i
)
48 // test sequence finding
53 test_attr("!@#$%^&* KEY : 123", x3::seek
[x3::lit("KEY") >> ':'] >> x3::int_
, i
, x3::space
)
62 BOOST_TEST( // expect partial match
63 test_attr("a06b78c3d", +x3::seek
[x3::int_
], v
, false)
64 && v
.size() == 3 && v
[0] == 6 && v
[1] == 78 && v
[2] == 3
72 auto const action
= [&b
]() { b
= true; };
74 BOOST_TEST( // expect partial match
75 test("abcdefg", x3::seek
["def"][action
], false)
85 test_attr("abcInt:100Int:95Int:44", x3::seek
[+("Int:" >> x3::int_
)], v
)
86 && v
.size() == 3 && v
[0] == 100 && v
[1] == 95 && v
[2] == 44
90 // test failure rollback
92 BOOST_TEST(test_failure("abcdefg", x3::seek
[x3::int_
]));
95 // past the end regression GH#658
96 BOOST_TEST(!test(" ", x3::seek
['x'], x3::space
));
98 return boost::report_errors();