Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56746 - branches/release/libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-12 12:46:39


Author: hkaiser
Date: 2009-10-12 12:46:39 EDT (Mon, 12 Oct 2009)
New Revision: 56746
URL: http://svn.boost.org/trac/boost/changeset/56746

Log:
Spirit: merging tests for bug fixes from trunk
Properties modified:
   branches/release/libs/spirit/test/qi/optional.cpp (contents, props changed)
Text files modified:
   branches/release/libs/spirit/test/qi/optional.cpp | 22 ++++++++++++++++++++++
   1 files changed, 22 insertions(+), 0 deletions(-)

Modified: branches/release/libs/spirit/test/qi/optional.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/optional.cpp (original)
+++ branches/release/libs/spirit/test/qi/optional.cpp 2009-10-12 12:46:39 EDT (Mon, 12 Oct 2009)
@@ -13,10 +13,23 @@
 #include <boost/spirit/include/support_argument.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/fusion/adapted/struct.hpp>
 
 #include <iostream>
 #include "test.hpp"
 
+struct adata
+{
+ int a;
+ boost::optional<int> b;
+};
+
+BOOST_FUSION_ADAPT_STRUCT(
+ adata,
+ (int, a)
+ (boost::optional<int>, b)
+)
+
 int
 main()
 {
@@ -65,5 +78,14 @@
         BOOST_TEST(!n);
     }
 
+ {
+ std::vector<adata> v;
+ BOOST_TEST((test_attr("a 1 2 a 2", *("a" >> int_ >> -int_), v
+ , char_(' '))));
+ BOOST_TEST(2 == v.size() &&
+ 1 == v[0].a && v[0].b && 2 == *(v[0].b) &&
+ 2 == v[1].a && !v[1].b);
+ }
+
     return boost::report_errors();
 }


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