]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/attr.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2015 Joel de Guzman
4 Distributed under the Boost Software License, Version 1. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/spirit/home/x3.hpp>
10 #include <boost/fusion/include/std_pair.hpp>
17 using spirit_test::test_attr
;
18 using boost::spirit::x3::attr
;
19 using boost::spirit::x3::int_
;
23 BOOST_TEST(test_attr("", attr(1), d
) && d
== 1);
26 BOOST_TEST(test_attr("", attr(d1
), d
) && d
== 1);
28 std::pair
<int, int> p
;
29 BOOST_TEST(test_attr("1", int_
>> attr(1), p
) &&
30 p
.first
== 1 && p
.second
== 1);
33 BOOST_TEST(test_attr("", attr('a'), c
) && c
== 'a');
35 // $$$ Needs some special is_convertible support, or
36 // str ends up with an explicit null-terminator... $$$
38 //~ BOOST_TEST(test_attr("", attr("test"), str) && str == "test");
40 int array
[] = {0, 1, 2};
42 BOOST_TEST(test_attr("", attr(array
), vec
) && vec
.size() == 3 &&
43 vec
[0] == 0 && vec
[1] == 1 && vec
[2] == 2);
48 BOOST_TEST(test_attr("s", "s" >> attr(std::string("123")), s
) &&
52 return boost::report_errors();