Merge updated tests from trunk (now float types tests are less strict, workaround MSVC2012 bug)

[SVN r80672]
This commit is contained in:
Antony Polukhin
2012-09-23 17:19:05 +00:00
parent 733438e072
commit 8d373a0c99
2 changed files with 20 additions and 7 deletions

View File

@@ -474,6 +474,11 @@ void test_wtraits()
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 @@ void test_allocator()
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 @@ void test_wallocator()
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

View File

@@ -105,13 +105,13 @@ void test_conversion_from_to_float_for_locale()
/*
* 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 @@ void test_conversion_from_to_float_for_locale()
#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 @@ void test_float_typess_for_overflows()
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 @@ void test_float_typess_for_overflows()
#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 \
);
/*