* reduces templates count
 * leaves only one lexical converting class (at least for modern compilers)
 * fixes small TODOs and XXXs from source code
 * makes lexical_stream_limited_src more readable
 * updates status/explicit-failures-markup.xml
 * makes lexical_cast_inf_nan_test.cpp pass on Itanium pltform
 * makes lexical_cast able to convert signed and unsigned chars to wchar_t
 and updates lexical_cast_wchars_test

[SVN r73313]
This commit is contained in:
Antony Polukhin
2011-07-23 15:55:54 +00:00
parent c1c8485cb4
commit 8a756eae7b
3 changed files with 356 additions and 827 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,7 @@
#include <boost/math/special_functions/sign.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
@@ -51,7 +52,14 @@ bool is_pos_nan(T value)
template <class T>
bool is_neg_nan(T value)
{
/* There is some strange behaviour on Itanium platform with -nan nuber for long double.
* It is a IA64 feature, or it is a boost::math feature, not a lexical_cast bug */
#if defined(__ia64__) || defined(_M_IA64)
return (boost::math::isnan)(value)
&& ( boost::is_same<T, long double >::value || (boost::math::signbit)(value) );
#else
return (boost::math::isnan)(value) && (boost::math::signbit)(value);
#endif
}
template <class T>
@@ -94,9 +102,11 @@ void test_inf_nan_templated()
== "-inf" );
BOOST_CHECK(lexical_cast<std::string>( std::numeric_limits<test_t >::infinity()) == "inf" );
BOOST_CHECK(lexical_cast<std::string>( std::numeric_limits<test_t >::quiet_NaN()) == "nan" );
#if !defined(__ia64__) && !defined(_M_IA64)
BOOST_CHECK(lexical_cast<std::string>(
(boost::math::changesign)(std::numeric_limits<test_t >::quiet_NaN()))
== "-nan" );
#endif
#ifndef BOOST_LCAST_NO_WCHAR_T
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>(L"inf") ) );
@@ -134,10 +144,13 @@ void test_inf_nan_templated()
== L"-inf" );
BOOST_CHECK(lexical_cast<std::wstring>( std::numeric_limits<test_t >::infinity()) == L"inf" );
BOOST_CHECK(lexical_cast<std::wstring>( std::numeric_limits<test_t >::quiet_NaN()) == L"nan" );
#if !defined(__ia64__) && !defined(_M_IA64)
BOOST_CHECK(lexical_cast<std::wstring>(
(boost::math::changesign)(std::numeric_limits<test_t >::quiet_NaN()))
== L"-nan" );
#endif
#endif
}
void test_inf_nan_float()

View File

@@ -37,11 +37,11 @@ void test_char_types_conversions()
BOOST_CHECK(boost::lexical_cast<wchar_t>(c_arr[0]) == wc_arr[0]);
BOOST_CHECK(boost::lexical_cast<std::wstring>(c_arr) == std::wstring(wc_arr));
BOOST_CHECK(boost::lexical_cast<std::wstring>(sc_arr) != std::wstring(wc_arr) );
BOOST_CHECK(boost::lexical_cast<std::wstring>(uc_arr) != std::wstring(wc_arr) );
BOOST_CHECK(boost::lexical_cast<std::wstring>(sc_arr) == std::wstring(wc_arr) );
BOOST_CHECK(boost::lexical_cast<std::wstring>(uc_arr) == std::wstring(wc_arr) );
BOOST_CHECK_THROW(boost::lexical_cast<wchar_t>(uc_arr[0]), boost::bad_lexical_cast);
BOOST_CHECK_THROW(boost::lexical_cast<wchar_t>(sc_arr[0]), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(uc_arr[0]), wc_arr[0]);
BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(sc_arr[0]), wc_arr[0]);
#endif
BOOST_CHECK(1);
}