Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80672 - in branches/release/libs/conversion: . test
From: antoshkka_at_[hidden]
Date: 2012-09-23 13:19:06


Author: apolukhin
Date: 2012-09-23 13:19:05 EDT (Sun, 23 Sep 2012)
New Revision: 80672
URL: http://svn.boost.org/trac/boost/changeset/80672

Log:
Merge updated tests from trunk (now float types tests are less strict, workaround MSVC2012 bug)
Text files modified:
   branches/release/libs/conversion/lexical_cast_test.cpp | 12 ++++++++++++
   branches/release/libs/conversion/test/lexical_cast_float_types_test.cpp | 15 ++++++++-------
   2 files changed, 20 insertions(+), 7 deletions(-)

Modified: branches/release/libs/conversion/lexical_cast_test.cpp
==============================================================================
--- branches/release/libs/conversion/lexical_cast_test.cpp (original)
+++ branches/release/libs/conversion/lexical_cast_test.cpp 2012-09-23 13:19:05 EDT (Sun, 23 Sep 2012)
@@ -474,6 +474,11 @@
 
 void test_allocator()
 {
+// Following test cause compilation error on MSVC2012:
+// (Reason: cannot convert from 'std::_Wrap_alloc<_Alloc>' to 'const my_allocator<CharT>')
+//
+// MSVC developer is notified about this issue
+#if !defined(_MSC_VER) || (_MSC_VER < 1700)
     typedef std::basic_string< char
                              , std::char_traits<char>
                              , my_allocator<char>
@@ -486,10 +491,16 @@
     BOOST_CHECK(boost::lexical_cast<my_string>(1) == "1");
     BOOST_CHECK(boost::lexical_cast<my_string>("s") == s);
     BOOST_CHECK(boost::lexical_cast<my_string>(std::string("s")) == s);
+#endif
 }
 
 void test_wallocator()
 {
+// Following test cause compilation error on MSVC2012:
+// (Reason: cannot convert from 'std::_Wrap_alloc<_Alloc>' to 'const my_allocator<CharT>')
+//
+// MSVC developer is notified about this issue
+#if !defined(_MSC_VER) || (_MSC_VER < 1700)
     typedef std::basic_string< wchar_t
                              , std::char_traits<wchar_t>
                              , my_allocator<wchar_t>
@@ -502,6 +513,7 @@
     BOOST_CHECK(boost::lexical_cast<my_string>(1) == L"1");
     BOOST_CHECK(boost::lexical_cast<my_string>(L"s") == s);
     BOOST_CHECK(boost::lexical_cast<my_string>(std::wstring(L"s")) == s);
+#endif
 }
 
 #endif

Modified: branches/release/libs/conversion/test/lexical_cast_float_types_test.cpp
==============================================================================
--- branches/release/libs/conversion/test/lexical_cast_float_types_test.cpp (original)
+++ branches/release/libs/conversion/test/lexical_cast_float_types_test.cpp 2012-09-23 13:19:05 EDT (Sun, 23 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