Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66938 - trunk/libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-11-30 18:42:09


Author: hkaiser
Date: 2010-11-30 18:42:03 EST (Tue, 30 Nov 2010)
New Revision: 66938
URL: http://svn.boost.org/trac/boost/changeset/66938

Log:
Spirit: more utree fixes for better integration with Qi, updated tests
Text files modified:
   trunk/libs/spirit/test/qi/utree.cpp | 29 ++++++++++++++++++++++++++---
   1 files changed, 26 insertions(+), 3 deletions(-)

Modified: trunk/libs/spirit/test/qi/utree.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/utree.cpp (original)
+++ trunk/libs/spirit/test/qi/utree.cpp 2010-11-30 18:42:03 EST (Tue, 30 Nov 2010)
@@ -67,6 +67,15 @@
         ut.clear();
         BOOST_TEST(test_attr("ab1.2", *~digit >> double_, ut) &&
             ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
+
+ rule<char const*, utree()> r = double_;
+
+ ut.clear();
+ BOOST_TEST(test_attr("1.2ab", r >> *char_, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1.2 \"a\" \"b\" )"));
+ ut.clear();
+ BOOST_TEST(test_attr("ab1.2", *~digit >> r, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( \"a\" \"b\" 1.2 )"));
     }
 
     // kleene star
@@ -108,6 +117,11 @@
         ut.clear();
         BOOST_TEST(test_attr("1.23,4.56", r3, ut) &&
             ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
+
+ rule<char const*, utree()> r4 = double_ % ',';
+ ut.clear();
+ BOOST_TEST(test_attr("1.23,4.56", r4, ut) &&
+ ut.which() == utree_type::list_type && check(ut, "( 1.23 4.56 )"));
     }
 
     // alternatives
@@ -126,13 +140,22 @@
         BOOST_TEST(test_attr("10.2", strict_double | int_, ut) &&
             ut.which() == utree_type::double_type && check(ut, "10.2"));
 
- rule<char const*, boost::variant<int, double>()> r = strict_double | int_;
+ rule<char const*, boost::variant<int, double>()> r1 = strict_double | int_;
+
+ ut.clear();
+ BOOST_TEST(test_attr("10", r1, ut) &&
+ ut.which() == utree_type::int_type && check(ut, "10"));
+ ut.clear();
+ BOOST_TEST(test_attr("10.2", r1, ut) &&
+ ut.which() == utree_type::double_type && check(ut, "10.2"));
+
+ rule<char const*, utree()> r2 = strict_double | int_;
 
         ut.clear();
- BOOST_TEST(test_attr("10", r, ut) &&
+ BOOST_TEST(test_attr("10", r2, ut) &&
             ut.which() == utree_type::int_type && check(ut, "10"));
         ut.clear();
- BOOST_TEST(test_attr("10.2", r, ut) &&
+ BOOST_TEST(test_attr("10.2", r2, ut) &&
             ut.which() == utree_type::double_type && check(ut, "10.2"));
     }
 


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