|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68707 - trunk/libs/spirit/phoenix/test/scope
From: hartmut.kaiser_at_[hidden]
Date: 2011-02-07 17:05:21
Author: hkaiser
Date: 2011-02-07 17:05:20 EST (Mon, 07 Feb 2011)
New Revision: 68707
URL: http://svn.boost.org/trac/boost/changeset/68707
Log:
Phoenix: fixing floating point comparisons
Text files modified:
trunk/libs/spirit/phoenix/test/scope/dynamic_tests.cpp | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
Modified: trunk/libs/spirit/phoenix/test/scope/dynamic_tests.cpp
==============================================================================
--- trunk/libs/spirit/phoenix/test/scope/dynamic_tests.cpp (original)
+++ trunk/libs/spirit/phoenix/test/scope/dynamic_tests.cpp 2011-02-07 17:05:20 EST (Mon, 07 Feb 2011)
@@ -6,6 +6,7 @@
==============================================================================*/
#include <iostream>
#include <string>
+#include <cmath>
#define PHOENIX_LIMIT 6
@@ -59,19 +60,19 @@
(std::cout << clos.message << clos.num << ", " << clos.real << '\n')();
BOOST_TEST(clos.num() == -1);
- BOOST_TEST(clos.real() == 3.14);
+ BOOST_TEST(std::fabs(clos.real() - 3.14) < 1e-8);
BOOST_TEST(clos.message() == "Direct Init ");
}
(std::cout << clos.message << clos.num << ", " << clos.real << '\n')();
BOOST_TEST(clos.num() == 987);
- BOOST_TEST(clos.real() == clos.num() * 1e30);
+ BOOST_TEST(std::fabs((clos.num() * 1e30) - clos.real()) < 1e-8);
BOOST_TEST(clos.message() == "Abracadabra ");
}
(std::cout << clos.message << clos.num << ", " << clos.real << '\n')();
BOOST_TEST(clos.num() == 123+456);
- BOOST_TEST(clos.real() == clos.num() / 56.5);
+ BOOST_TEST(std::fabs(clos.real() - (clos.num() / 56.5)) < 1e-8);
BOOST_TEST(clos.message() == "Hello " + std::string("World "));
}
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