Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69023 - trunk/libs/spirit/test/qi
From: joel_at_[hidden]
Date: 2011-02-19 04:15:04


Author: djowel
Date: 2011-02-19 04:15:03 EST (Sat, 19 Feb 2011)
New Revision: 69023
URL: http://svn.boost.org/trac/boost/changeset/69023

Log:
Tweaks. Allow attribute compatibility on alternatives
Text files modified:
   trunk/libs/spirit/test/qi/alternative.cpp | 47 ++++++++++++++++++++-------------------
   1 files changed, 24 insertions(+), 23 deletions(-)

Modified: trunk/libs/spirit/test/qi/alternative.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/alternative.cpp (original)
+++ trunk/libs/spirit/test/qi/alternative.cpp 2011-02-19 04:15:03 EST (Sat, 19 Feb 2011)
@@ -35,7 +35,7 @@
       , boost::spirit::unused_type
       , boost::spirit::unused_type) const
     {
- BOOST_TEST(v.size() == 4 &&
+ BOOST_TEST(v.size() == 4 &&
             v[0] == 'a' && v[1] == 'b' && v[2] == '1' && v[3] == last_);
     }
 
@@ -52,10 +52,10 @@
     {
         using boost::get;
 
- BOOST_TEST(v.size() == 5 &&
- v[1] == 'a' &&
- v[2] == 'b' &&
- v[3] == '1' &&
+ BOOST_TEST(v.size() == 5 &&
+ v[1] == 'a' &&
+ v[2] == 'b' &&
+ v[3] == '1' &&
             v[4] == '2');
     }
 };
@@ -97,18 +97,19 @@
         BOOST_TEST((test_attr("x", lit("rock") | int_ | char_, v)));
         BOOST_TEST(boost::get<char>(v) == 'x');
     }
-
- { // Make sure that we are using the actual supplied attribute types
+
+ { // Make sure that we are using the actual supplied attribute types
         // from the variant and not the expected type.
-// boost::variant<int, std::string> v;
-// BOOST_TEST((test_attr("12345", int_ | +char_, v)));
-// BOOST_TEST(boost::get<int>(v) == 12345);
-//
-// BOOST_TEST((test_attr("abc", int_ | +char_, v)));
-// BOOST_TEST(boost::get<std::string>(v) == "abc");
-//
-// BOOST_TEST((test_attr("12345", +char_ | int_, v)));
-// BOOST_TEST(boost::get<std::string>(v) == "12345");
+ // $$$ Fixed: <2/19/2011> JDG $$$
+ boost::variant<int, std::string> v;
+ BOOST_TEST((test_attr("12345", int_ | +char_, v)));
+ BOOST_TEST(boost::get<int>(v) == 12345);
+
+ BOOST_TEST((test_attr("abc", int_ | +char_, v)));
+ BOOST_TEST(boost::get<std::string>(v) == "abc");
+
+ BOOST_TEST((test_attr("12345", +char_ | int_, v)));
+ BOOST_TEST(boost::get<std::string>(v) == "12345");
     }
 
     { // test action
@@ -184,10 +185,10 @@
         std::vector<boost::optional<char> > v;
         BOOST_TEST( (test("x,y,z", (*(',' | char_))[phx::ref(v) = _1])) );
         BOOST_ASSERT(v[0] == 'x');
- BOOST_ASSERT(!v[1]);
+ BOOST_ASSERT(!v[1]);
         BOOST_ASSERT(v[2] == 'y');
- BOOST_ASSERT(!v[3]);
- BOOST_ASSERT(v[4] == 'z');
+ BOOST_ASSERT(!v[3]);
+ BOOST_ASSERT(v[4] == 'z');
     }
 
     {
@@ -195,23 +196,23 @@
 
         // testing a sequence taking a container as attribute
         std::string s;
- BOOST_TEST( (test_attr("abc,a,b,c",
+ BOOST_TEST( (test_attr("abc,a,b,c",
             char_ >> char_ >> (char_ % ','), s )) );
         BOOST_TEST(s == "abcabc");
 
         // test having an optional<container> inside a sequence
         s.erase();
- BOOST_TEST( (test_attr("ab",
+ BOOST_TEST( (test_attr("ab",
             char_ >> char_ >> -(char_ % ','), s )) );
         BOOST_TEST(s == "ab");
 
         // test having a variant<container, ...> inside a sequence
         s.erase();
- BOOST_TEST( (test_attr("ab",
+ BOOST_TEST( (test_attr("ab",
             char_ >> char_ >> ((char_ % ',') | eps), s )) );
         BOOST_TEST(s == "ab");
         s.erase();
- BOOST_TEST( (test_attr("abc",
+ BOOST_TEST( (test_attr("abc",
             char_ >> char_ >> ((char_ % ',') | eps), s )) );
         BOOST_TEST(s == "abc");
     }


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