|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58564 - in trunk/libs/spirit/test: karma qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-12-29 11:37:18
Author: hkaiser
Date: 2009-12-29 11:37:17 EST (Tue, 29 Dec 2009)
New Revision: 58564
URL: http://svn.boost.org/trac/boost/changeset/58564
Log:
Spirit: fixing a problem in sequences if the attribute is a container of containers, more test cases
Text files modified:
trunk/libs/spirit/test/karma/sequence.cpp | 18 ++++++++++++++++--
trunk/libs/spirit/test/qi/sequence.cpp | 26 ++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
Modified: trunk/libs/spirit/test/karma/sequence.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/sequence.cpp (original)
+++ trunk/libs/spirit/test/karma/sequence.cpp 2009-12-29 11:37:17 EST (Tue, 29 Dec 2009)
@@ -103,8 +103,8 @@
upper[lit("begin") << "nend"], char(' ')));
BOOST_TEST(test("Aa ", left_align[char_('A') << 'a']));
-// BOOST_TEST(test(" Aa ", center[char_('A') << 'a']));
-// BOOST_TEST(test(" Aa", right_align[char_('A') << 'a']));
+ BOOST_TEST(test(" Aa ", center[char_('A') << 'a']));
+ BOOST_TEST(test(" Aa", right_align[char_('A') << 'a']));
}
{
@@ -163,6 +163,20 @@
BOOST_TEST(test(">1,2,3,4", '>' << r, v));
}
+ {
+ namespace karma = boost::spirit::karma;
+ typedef spirit_test::output_iterator<char>::type outiter_type;
+
+ karma::rule<outiter_type, std::string()> e = karma::string;
+ karma::rule<outiter_type, std::vector<std::string>()> l = e << *(',' << e);
+
+ std::vector<std::string> v;
+ v.push_back("abc1");
+ v.push_back("abc2");
+ v.push_back("abc3");
+ BOOST_TEST(test("abc1,abc2,abc3", l, v));
+ }
+
return boost::report_errors();
}
Modified: trunk/libs/spirit/test/qi/sequence.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/sequence.cpp (original)
+++ trunk/libs/spirit/test/qi/sequence.cpp 2009-12-29 11:37:17 EST (Tue, 29 Dec 2009)
@@ -148,6 +148,32 @@
}
+ // alternative forms of attributes. Allow sequences to take in
+ // stl containers of stl containers.
+// {
+// // this use case still does not compile, needs some additional work
+//
+// std::vector<std::string> v;
+// BOOST_TEST(test_attr("abc1,abc2,abc3",
+// *~char_(',') >> *(',' >> *~char_(',')), v));
+// BOOST_TEST(v.size() == 3);
+// BOOST_TEST(v[0] == "abc1");
+// BOOST_TEST(v[1] == "abc2");
+// BOOST_TEST(v[2] == "abc3");
+// }
+
+ {
+ std::vector<std::string> v;
+ rule<char const*, std::string()> e = *~char_(',');
+ rule<char const*, std::vector<std::string>()> l = e >> *(',' >> e);
+
+ BOOST_TEST(test_attr("abc1,abc2,abc3", l, v));
+ BOOST_TEST(v.size() == 3);
+ BOOST_TEST(v[0] == "abc1");
+ BOOST_TEST(v[1] == "abc2");
+ BOOST_TEST(v[2] == "abc3");
+ }
+
{
std::vector<char> v;
BOOST_TEST(test_attr("ab", char_ >> -char_, v));
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