|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55101 - trunk/libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-22 21:26:26
Author: hkaiser
Date: 2009-07-22 21:26:26 EDT (Wed, 22 Jul 2009)
New Revision: 55101
URL: http://svn.boost.org/trac/boost/changeset/55101
Log:
Spirit: more test cases for list parsers
Text files modified:
trunk/libs/spirit/test/qi/list.cpp | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
Modified: trunk/libs/spirit/test/qi/list.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/list.cpp (original)
+++ trunk/libs/spirit/test/qi/list.cpp 2009-07-22 21:26:26 EDT (Wed, 22 Jul 2009)
@@ -6,6 +6,8 @@
=============================================================================*/
#include <string>
#include <vector>
+#include <set>
+#include <map>
#include <boost/detail/lightweight_test.hpp>
#include <boost/utility/enable_if.hpp>
@@ -21,6 +23,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
+#include <boost/fusion/include/std_pair.hpp>
#include <string>
#include <iostream>
@@ -81,6 +84,30 @@
boost::get<std::string>(v[1])[0] == '\0');
}
+ {
+ typedef std::set<std::pair<std::string, std::string> > set_type;
+ set_type s;
+ BOOST_TEST(test_attr("k1=v1&k2=v2",
+ (*(char_ - '=') >> '=' >> *(char_ - '&')) % '&', s));
+
+ set_type::const_iterator it = s.begin();
+ BOOST_TEST(s.size() == 2);
+ BOOST_TEST(it != s.end() && (*it).first == "k1" && (*it).second == "v1");
+ BOOST_TEST(++it != s.end() && (*it).first == "k2" && (*it).second == "v2");
+ }
+
+ {
+ typedef std::map<std::string, std::string> map_type;
+ map_type m;
+ BOOST_TEST(test_attr("k1=v1&k2=v2",
+ (*(char_ - '=') >> '=' >> *(char_ - '&')) % '&', m));
+
+ map_type::const_iterator it = m.begin();
+ BOOST_TEST(m.size() == 2);
+ BOOST_TEST(it != m.end() && (*it).first == "k1" && (*it).second == "v1");
+ BOOST_TEST(++it != m.end() && (*it).first == "k2" && (*it).second == "v2");
+ }
+
{ // actions
namespace phx = boost::phoenix;
using boost::phoenix::begin;
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