|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55367 - in trunk/libs/spirit/test: karma qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-08-02 13:55:14
Author: hkaiser
Date: 2009-08-02 13:55:13 EDT (Sun, 02 Aug 2009)
New Revision: 55367
URL: http://svn.boost.org/trac/boost/changeset/55367
Log:
Spirit: added some test cases for special attribute handling in sequences
Text files modified:
trunk/libs/spirit/test/karma/sequence.cpp | 11 +++++++++++
trunk/libs/spirit/test/qi/no_case.cpp | 4 ++--
trunk/libs/spirit/test/qi/sequence.cpp | 13 +++++++++++++
3 files changed, 26 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-08-02 13:55:13 EDT (Sun, 02 Aug 2009)
@@ -15,6 +15,7 @@
#include <boost/spirit/include/karma_operator.hpp>
#include <boost/spirit/include/karma_directive.hpp>
#include <boost/spirit/include/karma_action.hpp>
+#include <boost/spirit/include/karma_nonterminal.hpp>
#include <boost/spirit/include/support_unused.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
@@ -106,6 +107,16 @@
// BOOST_TEST(test(" Aa", right_align[char_('A') << 'a']));
}
+ {
+ // make sure single element tuples get passed through if the rhs
+ // has a single element tuple as its attribute
+ typedef spirit_test::output_iterator<char>::type iterator_type;
+ fusion::vector<double, int> fv(2.0, 1);
+ karma::rule<iterator_type, fusion::vector<double, int>()> r;
+ r %= double_ << ',' << int_;
+ BOOST_TEST(test("test:2.0,1", "test:" << r, fv));
+ }
+
// action tests
{
using namespace boost::phoenix;
Modified: trunk/libs/spirit/test/qi/no_case.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/no_case.cpp (original)
+++ trunk/libs/spirit/test/qi/no_case.cpp 2009-08-02 13:55:13 EDT (Sun, 02 Aug 2009)
@@ -1,9 +1,9 @@
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
- include/qi_://spirit.sourceforge.net/
+ http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at include/qi_://www.boost.org/LICENSE_1_0.txt)
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/include/qi_char.hpp>
Modified: trunk/libs/spirit/test/qi/sequence.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/sequence.cpp (original)
+++ trunk/libs/spirit/test/qi/sequence.cpp 2009-08-02 13:55:13 EDT (Sun, 02 Aug 2009)
@@ -11,6 +11,7 @@
#include <boost/spirit/include/qi_numeric.hpp>
#include <boost/spirit/include/qi_directive.hpp>
#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/qi_nonterminal.hpp>
#include <boost/spirit/include/support_argument.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
@@ -27,7 +28,9 @@
using boost::spirit::qi::lit;
using boost::spirit::qi::unused;
using boost::spirit::qi::int_;
+ using boost::spirit::qi::double_;
using boost::spirit::qi::what;
+ using boost::spirit::qi::rule;
using boost::spirit::qi::_1;
using boost::spirit::qi::_2;
@@ -96,6 +99,16 @@
}
{
+ // make sure single element tuples get passed through if the rhs
+ // has a single element tuple as its attribute
+ vector<double, int> fv;
+ rule<char const*, vector<double, int>()> r;
+ r %= double_ >> ',' >> int_;
+ BOOST_TEST((test_attr("test:2.0,1", "test:" >> r, fv) &&
+ fv == vector<double, int>(2.0, 1)));
+ }
+
+ {
// unused means we don't care about the attribute
BOOST_TEST((test_attr("abc", char_ >> 'b' >> char_, unused)));
}
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