Ticket #5713: test.cpp

File test.cpp, 1.1 KB (added by Jamboree <tongari95@…>, 11 years ago)

test case

Line 
1#include <boost/detail/lightweight_test.hpp>
2#include <boost/spirit/include/qi.hpp>
3#include <boost/fusion/include/vector.hpp>
4#include <boost/spirit/include/phoenix_core.hpp>
5#include <boost/spirit/include/phoenix_operator.hpp>
6
7#include <string>
8#include <iostream>
9#include "test.hpp"
10
11using namespace spirit_test;
12
13int
14main()
15{
16 using boost::spirit::qi::int_;
17 using boost::spirit::qi::rule;
18 using boost::spirit::qi::_1;
19 using boost::spirit::qi::space;
20 using boost::spirit::qi::space_type;
21 using boost::fusion::vector;
22
23 typedef vector<int, int> V;
24 typedef rule<char const*, V(), space_type> R;
25
26 {
27 V val;
28 R r;
29 r %= int_ >> int_;
30 BOOST_TEST((test_attr("1 5", r, val, space) && val == V(1, 5)));
31 }
32
33 {
34 V val;
35 R r;
36 r %= int_ >> int_[_1];
37 BOOST_TEST((test_attr("1 5", r, val, space) && val == V(1, 5)));
38 }
39
40 {
41 V val;
42 R r;
43 r %= (int_ >> int_)[_1];
44 BOOST_TEST((test_attr("1 5", r, val, space) && val == V(1, 5)));
45 }
46
47 return boost::report_errors();
48}
49