Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67712 - in trunk/libs/spirit/test: karma qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-01-05 22:12:04


Author: hkaiser
Date: 2011-01-05 22:12:02 EST (Wed, 05 Jan 2011)
New Revision: 67712
URL: http://svn.boost.org/trac/boost/changeset/67712

Log:
Spirit: added more tests
Text files modified:
   trunk/libs/spirit/test/karma/alternative1.cpp | 2 +-
   trunk/libs/spirit/test/karma/alternative2.cpp | 2 +-
   trunk/libs/spirit/test/qi/utree2.cpp | 30 +++++++++++++++++++++++++++++-
   3 files changed, 31 insertions(+), 3 deletions(-)

Modified: trunk/libs/spirit/test/karma/alternative1.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/alternative1.cpp (original)
+++ trunk/libs/spirit/test/karma/alternative1.cpp 2011-01-05 22:12:02 EST (Wed, 05 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Modified: trunk/libs/spirit/test/karma/alternative2.cpp
==============================================================================
--- trunk/libs/spirit/test/karma/alternative2.cpp (original)
+++ trunk/libs/spirit/test/karma/alternative2.cpp 2011-01-05 22:12:02 EST (Wed, 05 Jan 2011)
@@ -1,4 +1,4 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
+// Copyright (c) 2001-2011 Hartmut Kaiser
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Modified: trunk/libs/spirit/test/qi/utree2.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/utree2.cpp (original)
+++ trunk/libs/spirit/test/qi/utree2.cpp 2011-01-05 22:12:02 EST (Wed, 05 Jan 2011)
@@ -10,12 +10,31 @@
 
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/support_utree.hpp>
-#include <boost/mpl/print.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 #include <sstream>
 
 #include "test.hpp"
 
+template <typename Expr, typename Iterator = boost::spirit::unused_type>
+struct attribute_of_parser
+{
+ typedef typename boost::spirit::result_of::compile<
+ boost::spirit::qi::domain, Expr
+ >::type parser_expression_type;
+
+ typedef typename boost::spirit::traits::attribute_of<
+ parser_expression_type, boost::spirit::unused_type, Iterator
+ >::type type;
+};
+
+template <typename Expected, typename Expr>
+inline bool compare_attribute_type(Expr const&)
+{
+ typedef typename attribute_of_parser<Expr>::type type;
+ return boost::is_same<type, Expected>::value;
+}
+
 inline bool check(boost::spirit::utree const& val, std::string expected)
 {
     std::stringstream s;
@@ -98,6 +117,15 @@
         ut.clear();
     }
 
+ // special attribute transformation for utree in alternatives
+ {
+ rule<char const*, utree()> r1;
+ rule<char const*, utree::list_type()> r2;
+
+ BOOST_TEST(compare_attribute_type<utree>(
+ r1 | -r1 | *r1 | r2 | -r2 | *r2));
+ }
+
     // lists
     {
         utree ut;


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