|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61324 - in trunk/libs/spirit/test: karma qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-04-16 14:15:20
Author: hkaiser
Date: 2010-04-16 14:15:19 EDT (Fri, 16 Apr 2010)
New Revision: 61324
URL: http://svn.boost.org/trac/boost/changeset/61324
Log:
Spirit: enabled single element sequences everywhere a single value is expected (Qi, Karma), added tests
Text files modified:
trunk/libs/spirit/test/karma/pattern2.cpp | 17 +++++++++++++++++
trunk/libs/spirit/test/qi/rule.cpp | 23 +++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
Modified: trunk/libs/spirit/test/karma/pattern2.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/pattern2.cpp (original)
+++ trunk/libs/spirit/test/karma/pattern2.cpp 2010-04-16 14:15:19 EDT (Fri, 16 Apr 2010)
@@ -100,6 +100,23 @@
BOOST_TEST(test_delimited("12.4 ", start, v, space));
}
+ // test handling of single element fusion sequences
+ {
+ using boost::fusion::vector;
+ karma::rule<outiter_type, vector<int>()> r = int_;
+
+ vector<int> v = 1;
+ BOOST_TEST(test("1", r, v));
+ }
+
+ {
+ using boost::fusion::vector;
+ karma::rule<outiter_type, space_type, vector<int>()> r = int_;
+
+ vector<int> v = 1;
+ BOOST_TEST(test_delimited("1 ", r, v, space));
+ }
+
return boost::report_errors();
}
Modified: trunk/libs/spirit/test/qi/rule.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/rule.cpp (original)
+++ trunk/libs/spirit/test/qi/rule.cpp 2010-04-16 14:15:19 EDT (Fri, 16 Apr 2010)
@@ -447,6 +447,29 @@
#pragma setlocale("")
#endif
+ {
+ typedef boost::variant<double, int> v_type;
+ rule<const char*, v_type()> r1 = int_;
+ v_type v;
+ BOOST_TEST(test_attr("1", r1, v) && v.which() == 1 &&
+ boost::get<int>(v) == 1);
+
+ typedef boost::optional<int> ov_type;
+ rule<const char*, ov_type()> r2 = int_;
+ ov_type ov;
+ BOOST_TEST(test_attr("1", r2, ov) && ov && boost::get<int>(ov) == 1);
+ }
+
+ // test handling of single element fusion sequences
+ {
+ using boost::fusion::vector;
+ using boost::fusion::at_c;
+ rule<const char*, vector<int>()> r = int_;
+
+ vector<int> v = 0;
+ BOOST_TEST(test_attr("1", r, v) && at_c<0>(v) == 1);
+ }
+
return boost::report_errors();
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk