Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71231 - in trunk/libs/spirit/test: . karma
From: hartmut.kaiser_at_[hidden]
Date: 2011-04-13 17:54:17


Author: hkaiser
Date: 2011-04-13 17:54:16 EDT (Wed, 13 Apr 2011)
New Revision: 71231
URL: http://svn.boost.org/trac/boost/changeset/71231

Log:
Spirit: adding missing numeric CP specializations for adapted ADTs, added test
Added:
   trunk/libs/spirit/test/karma/regression_numerics_adapt_adt.cpp (contents, props changed)
Text files modified:
   trunk/libs/spirit/test/Jamfile | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2011-04-13 17:54:16 EDT (Wed, 13 Apr 2011)
@@ -241,6 +241,7 @@
      [ run karma/regression_semantic_action_attribute.cpp : : : : karma_regression_semantic_action_attribute ]
      [ run karma/regression_real_scientific.cpp : : : : karma_regression_real_scientific ]
      [ compile karma/regression_const_real_policies.cpp : : regression_const_real_policies ]
+ [ run karma/regression_numerics_adapt_adt.cpp : : : : karma_regression_numerics_adapt_adt ]
 
     ;
 

Added: trunk/libs/spirit/test/karma/regression_numerics_adapt_adt.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/regression_numerics_adapt_adt.cpp 2011-04-13 17:54:16 EDT (Wed, 13 Apr 2011)
@@ -0,0 +1,61 @@
+// Copyright (c) 2001-2011 Hartmut Kaiser
+// Copyright (c) 2011 Colin Rundel
+//
+// 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)
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/fusion/include/adapt_adt.hpp>
+
+#include <boost/spirit/include/karma.hpp>
+#include <boost/spirit/include/support_adapt_adt_attributes.hpp>
+
+#include "test.hpp"
+
+///////////////////////////////////////////////////////////////////////////////
+class box
+{
+private:
+ int width_;
+ int height_;
+
+public:
+
+ box()
+ : width_(400),
+ height_(400) {}
+
+ box(int width, int height)
+ : width_(width),
+ height_(height) {}
+
+ int width() const { return width_;}
+ int height() const { return height_;}
+
+ void set_width(int width) { width_=width;}
+ void set_height(int height) { height_=height;}
+};
+
+BOOST_FUSION_ADAPT_ADT(
+ box,
+ (int, int, obj.width(), obj.set_width(val) )
+ (int, int, obj.height(), obj.set_height(val) )
+);
+
+///////////////////////////////////////////////////////////////////////////////
+int main ()
+{
+ using spirit_test::test;
+
+ {
+ using boost::spirit::karma::int_;
+
+ box b(800, 600);
+ BOOST_TEST(test("width: 800\nheight: 600\n",
+ "width: " << int_ << "\n" << "height: " << int_ << "\n", 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