|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81160 - in trunk: boost/spirit/home/karma/numeric/detail libs/spirit/test libs/spirit/test/karma
From: hartmut.kaiser_at_[hidden]
Date: 2012-11-03 11:16:57
Author: hkaiser
Date: 2012-11-03 11:16:56 EDT (Sat, 03 Nov 2012)
New Revision: 81160
URL: http://svn.boost.org/trac/boost/changeset/81160
Log:
Spirit: fixed #7635: Karma real generators output "inf" when attribute is integral 0
Added:
trunk/libs/spirit/test/karma/regression_real_0.cpp (contents, props changed)
Text files modified:
trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp | 2 ++
trunk/libs/spirit/test/Jamfile | 3 ++-
2 files changed, 4 insertions(+), 1 deletions(-)
Modified: trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp 2012-11-03 11:16:56 EDT (Sat, 03 Nov 2012)
@@ -285,6 +285,8 @@
{
static bool call(T n)
{
+ if (!std::numeric_limits<T>::has_infinity)
+ return false;
return (n == std::numeric_limits<T>::infinity()) ? true : false;
}
};
Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2012-11-03 11:16:56 EDT (Sat, 03 Nov 2012)
@@ -249,7 +249,8 @@
[ run karma/regression_semantic_action_attribute.cpp : : : : karma_regression_semantic_action_attribute ]
[ run karma/regression_real_scientific.cpp : : : : karma_regression_real_scientific ]
[ run karma/regression_center_alignment.cpp : : : : karma_regression_center_alignment ]
- [ run karma/regression_container_variant_sequence.cpp : : : : regression_container_variant_sequence ]
+ [ run karma/regression_container_variant_sequence.cpp : : : : karma_regression_container_variant_sequence ]
+ [ run karma/regression_real_0.cpp : : : : karma_regression_real_0 ]
;
Added: trunk/libs/spirit/test/karma/regression_real_0.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/karma/regression_real_0.cpp 2012-11-03 11:16:56 EDT (Sat, 03 Nov 2012)
@@ -0,0 +1,24 @@
+// Copyright (c) 2012 Agustín K-ballo Berge
+// Copyright (c) 2001-2012 Hartmut Kaiser
+//
+// 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/spirit/include/karma.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <iterator>
+#include <sstream>
+#include <string>
+
+int main( int argc, char** argv )
+{
+ namespace karma = boost::spirit::karma;
+ std::string output;
+ std::back_insert_iterator< std::string > sink = std::back_inserter( output );
+ karma::generate( sink, karma::double_, 0 ); // prints ¨inf¨ instead of ¨0.0¨
+ BOOST_TEST((output == "0.0"));
+ 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