From c0c02e560e7a6a1be094606bfb67b30ad1b2353a Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 18 Nov 2013 08:17:33 +0000 Subject: [PATCH] Attempt to catch libc++ bug with a modified tests [SVN r86747] --- test/lexical_cast_integral_types_test.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/lexical_cast_integral_types_test.cpp b/test/lexical_cast_integral_types_test.cpp index e537a4b..551a349 100644 --- a/test/lexical_cast_integral_types_test.cpp +++ b/test/lexical_cast_integral_types_test.cpp @@ -373,7 +373,7 @@ void test_conversion_from_to_integral_for_locale() // This is a part of test_conversion_from_integral_to_string('0') method, // but with BOOST_CHECK_EQUAL instead of BOOST_CHECK. It is required to see // what is produced by the to_str(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 limits; T t = (limits::min)(); BOOST_CHECK_EQUAL(lexical_cast(t), to_str(t)); @@ -381,6 +381,22 @@ void test_conversion_from_to_integral_for_locale() test_conversion_from_integral_to_string('0'); test_conversion_from_string_to_integral('0'); #if !defined(BOOST_LCAST_NO_WCHAR_T) + if (lexical_cast(t) != to_str(t)) { + // Something went wrong, and now we are attempting to find and print the + // difference. + std::wstring wstr = to_str(t); + std::string lcast_str = lexical_cast(t); + std::string str; + str.reserve(wstr.size()); + for (std::size_t i = 0; i < wstr.size(); ++i) { + str.push_back(static_cast(wstr[i])); + } + + BOOST_CHECK_EQUAL(lcast_str.length(), lexical_cast(t).length()); + BOOST_CHECK_EQUAL(to_str(t), str); + BOOST_CHECK_EQUAL(lcast_str, str); + } + test_conversion_from_integral_to_string(L'0'); test_conversion_from_string_to_integral(L'0'); #endif