forked from boostorg/conversion
Fix float types tests, make them less strict (so that MSVC2012 could pass it)
[SVN r80438]
This commit is contained in:
@ -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 \
|
||||
);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user