1 /*=============================================================================
2 Copyright (c) 2001-2013 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>
18 using spirit_test::test_attr;
19 using boost::spirit::x3::attr;
20 using boost::spirit::x3::int_;
24 BOOST_TEST(test_attr("", attr(1), d) && d == 1);
27 BOOST_TEST(test_attr("", attr(d1), d) && d == 1);
29 std::pair<int, int> p;
30 BOOST_TEST(test_attr("1", int_ >> attr(1), p) &&
31 p.first == 1 && p.second == 1);
34 BOOST_TEST(test_attr("", attr('a'), c) && c == 'a');
36 // $$$ Needs some special is_convertible support, or
37 // str ends up with an explicit null-terminator... $$$
39 //~ BOOST_TEST(test_attr("", attr("test"), str) && str == "test");
41 int array[] = {0, 1, 2};
43 BOOST_TEST(test_attr("", attr(array), vec) && vec.size() == 3 &&
44 vec[0] == 0 && vec[1] == 1 && vec[2] == 2);
47 //~ { // testing lazy constructs
48 //~ using boost::phoenix::val;
49 //~ using boost::phoenix::ref;
52 //~ BOOST_TEST(test_attr("", attr(val(1)), d) && d == 1);
55 //~ BOOST_TEST(test_attr("", attr(ref(d1)), d) && d == 2);
60 BOOST_TEST(test_attr("s", "s" >> attr(std::string("123")), s) &&
64 return boost::report_errors();