Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86747 - trunk/libs/conversion/test
From: antoshkka_at_[hidden]
Date: 2013-11-18 03:17:33


Author: apolukhin
Date: 2013-11-18 03:17:33 EST (Mon, 18 Nov 2013)
New Revision: 86747
URL: http://svn.boost.org/trac/boost/changeset/86747

Log:
Attempt to catch libc++ bug with a modified tests

Text files modified:
   trunk/libs/conversion/test/lexical_cast_integral_types_test.cpp | 18 +++++++++++++++++-
   1 files changed, 17 insertions(+), 1 deletions(-)

Modified: trunk/libs/conversion/test/lexical_cast_integral_types_test.cpp
==============================================================================
--- trunk/libs/conversion/test/lexical_cast_integral_types_test.cpp Mon Nov 18 01:08:02 2013 (r86746)
+++ trunk/libs/conversion/test/lexical_cast_integral_types_test.cpp 2013-11-18 03:17:33 EST (Mon, 18 Nov 2013) (r86747)
@@ -373,7 +373,7 @@
     // This is a part of test_conversion_from_integral_to_string<T>('0') method,
     // but with BOOST_CHECK_EQUAL instead of BOOST_CHECK. It is required to see
     // what is produced by the to_str<char>(t) method in situations when result
- // is different. BOOST_CHECK does not work with wchat_t.
+ // is different. BOOST_CHECK does not work with wchar_t.
     typedef std::numeric_limits<T> limits;
     T t = (limits::min)();
     BOOST_CHECK_EQUAL(lexical_cast<std::string>(t), to_str<char>(t));
@@ -381,6 +381,22 @@
     test_conversion_from_integral_to_string<T>('0');
     test_conversion_from_string_to_integral<T>('0');
 #if !defined(BOOST_LCAST_NO_WCHAR_T)
+ if (lexical_cast<std::wstring>(t) != to_str<wchar_t>(t)) {
+ // Something went wrong, and now we are attempting to find and print the
+ // difference.
+ std::wstring wstr = to_str<wchar_t>(t);
+ std::string lcast_str = lexical_cast<std::string>(t);
+ std::string str;
+ str.reserve(wstr.size());
+ for (std::size_t i = 0; i < wstr.size(); ++i) {
+ str.push_back(static_cast<char>(wstr[i]));
+ }
+
+ BOOST_CHECK_EQUAL(lcast_str.length(), lexical_cast<std::wstring>(t).length());
+ BOOST_CHECK_EQUAL(to_str<char>(t), str);
+ BOOST_CHECK_EQUAL(lcast_str, str);
+ }
+
     test_conversion_from_integral_to_string<T>(L'0');
     test_conversion_from_string_to_integral<T>(L'0');
 #endif


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