Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80438 - trunk/libs/conversion/test
From: antoshkka_at_[hidden]
Date: 2012-09-07 21:44:19


Author: apolukhin
Date: 2012-09-07 21:44:18 EDT (Fri, 07 Sep 2012)
New Revision: 80438
URL: http://svn.boost.org/trac/boost/changeset/80438

Log:
Fix float types tests, make them less strict (so that MSVC2012 could pass it)
Text files modified:
   trunk/libs/conversion/test/lexical_cast_float_types_test.cpp | 15 ++++++++-------
   1 files changed, 8 insertions(+), 7 deletions(-)

Modified: trunk/libs/conversion/test/lexical_cast_float_types_test.cpp
==============================================================================
--- trunk/libs/conversion/test/lexical_cast_float_types_test.cpp (original)
+++ trunk/libs/conversion/test/lexical_cast_float_types_test.cpp 2012-09-07 21:44:18 EDT (Fri, 07 Sep 2012)
@@ -105,13 +105,13 @@
 
 
 /*
- * Converts char* [and wchar_t] to float number type and checks, that generated
- * number is in interval [base_value-epsilon, base_value+epsilon].
+ * Converts char* [and wchar_t*] to float number type and checks, that generated
+ * number does not exceeds allowed epsilon.
  */
 #ifndef BOOST_LCAST_NO_WCHAR_T
 #define CHECK_CLOSE_ABS_DIFF(VAL,PREFIX) \
     converted_val = lexical_cast<test_t>(#VAL); \
- BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
+ BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
                        (converted_val ? converted_val : std::numeric_limits<test_t>::epsilon()), \
                        std::numeric_limits<test_t>::epsilon() \
                      ); \
@@ -120,7 +120,7 @@
 #else
 #define CHECK_CLOSE_ABS_DIFF(VAL,TYPE) \
     converted_val = lexical_cast<test_t>(#VAL); \
- BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
+ BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
                        (converted_val ? converted_val : std::numeric_limits<test_t>::epsilon()), \
                        std::numeric_limits<test_t>::epsilon() \
                      );
@@ -287,7 +287,7 @@
     test_t minvalue = (std::numeric_limits<test_t>::min)();
     std::string s_min_value = lexical_cast<std::string>(minvalue);
     BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast<test_t>(minvalue), (std::numeric_limits<test_t>::epsilon()));
- BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast<test_t>(s_min_value), (std::numeric_limits<test_t>::epsilon()));
+ BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast<test_t>(s_min_value), (std::numeric_limits<test_t>::epsilon() * 2));
 
     test_t maxvalue = (std::numeric_limits<test_t>::max)();
     std::string s_max_value = lexical_cast<std::string>(maxvalue);
@@ -326,13 +326,14 @@
 
 #undef CHECK_CLOSE_ABS_DIFF
 
+// Epsilon is multiplied by 2 because of two lexical conversions
 #define TEST_TO_FROM_CAST_AROUND_TYPED(VAL,STRING_TYPE) \
     test_value = VAL + std::numeric_limits<test_t>::epsilon() * i ; \
     converted_val = lexical_cast<test_t>( lexical_cast<STRING_TYPE>(test_value) ); \
- BOOST_CHECK_CLOSE_FRACTION( \
+ BOOST_CHECK_CLOSE_FRACTION( \
             test_value, \
             converted_val, \
- std::numeric_limits<test_t>::epsilon() \
+ std::numeric_limits<test_t>::epsilon() * 2 \
         );
 
 /*


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