|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74055 - in trunk/libs/spirit/test: . qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-08-24 18:24:52
Author: hkaiser
Date: 2011-08-24 18:24:51 EDT (Wed, 24 Aug 2011)
New Revision: 74055
URL: http://svn.boost.org/trac/boost/changeset/74055
Log:
Spirit: Fixing actions for embedded parsers which synthesize attributes, adding test
Added:
trunk/libs/spirit/test/qi/regression_binary_action.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-08-24 18:24:51 EDT (Wed, 24 Aug 2011)
@@ -160,6 +160,7 @@
[ run qi/regression_reorder.cpp : : : : qi_regression_reorder ]
[ run qi/regression_repeat.cpp : : : : qi_regression_repeat ]
[ run qi/regression_transform_assignment.cpp : : : : qi_regression_transform_assignment ]
+ [ run qi/regression_binary_action.cpp : : : : qi_regression_binary_action ]
;
###########################################################################
Added: trunk/libs/spirit/test/qi/regression_binary_action.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/regression_binary_action.cpp 2011-08-24 18:24:51 EDT (Wed, 24 Aug 2011)
@@ -0,0 +1,47 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Hartmut Kaiser
+ Copyright (c) 2011 Matthias Born
+
+ 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/spirit/include/qi.hpp>
+#include <boost/spirit/include/phoenix.hpp>
+#include <boost/fusion/include/adapt_struct.hpp>
+#include "test.hpp"
+
+int main()
+{
+// This test assumes a little endian architecture
+#ifdef BOOST_LITTLE_ENDIAN
+ using spirit_test::test_attr;
+ using boost::spirit::qi::rule;
+ using boost::spirit::qi::locals;
+ using boost::spirit::qi::little_word;
+ using boost::spirit::qi::omit;
+ using boost::spirit::qi::_1;
+ using boost::spirit::qi::_a;
+ using boost::spirit::qi::attr;
+
+ rule<char const*, short int(), locals<short int> > pass;
+ pass = little_word;
+
+ rule<char const*, short int(), locals<short int> > pass_ugly;
+ pass_ugly %= omit[little_word[_a=_1]] >> attr(_a);
+
+ rule<char const*, short int(), locals<short int> > fail;
+ fail %= little_word[_a=_1];
+
+ short int us = 0;
+ BOOST_TEST(test_attr("\x01\x02", pass, us) && us == 0x0201);
+
+ us = 0;
+ BOOST_TEST(test_attr("\x01\x02", pass_ugly, us) && us == 0x0201);
+
+ us = 0;
+ BOOST_TEST(test_attr("\x01\x02", fail, us) && us == 0x0201);
+#endif
+ 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