forked from boostorg/conversion
More strict tests, less workarounds, bugfixes (refs #7814)
[SVN r82227]
This commit is contained in:
1 parent
565e2882d3
commit
63b680c082
3 files changed
+56
-59
No files matched your search
+10
-6
@@ -12,7 +12,9 @@ project
|
||||
: requirements
|
||||
<library>/boost/test//boost_unit_test_framework
|
||||
<link>static
|
||||
<toolset>gcc-4.8:<define>BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
|
||||
<toolset>gcc-4.7:<cxxflags>-ftrapv
|
||||
<toolset>gcc-4.6:<cxxflags>-ftrapv
|
||||
<toolset>clang:<cxxflags>-ftrapv
|
||||
;
|
||||
|
||||
# Thanks to Steven Watanabe for helping with <nowchar> feature
|
||||
@@ -40,11 +42,13 @@ test-suite conversion
|
||||
[ run lexical_cast_typedefed_wchar_test_runtime.cpp : : : <toolset>msvc:<nowchar>on <toolset>msvc,<stdlib>stlport:<build>no ]
|
||||
[ run lexical_cast_no_locale_test.cpp : : : <define>BOOST_NO_STD_LOCALE <define>BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ]
|
||||
[ run lexical_cast_no_exceptions_test.cpp : : : <define>BOOST_NO_EXCEPTIONS
|
||||
<toolset>gcc-4.3:<cflags>-fno-exceptions
|
||||
<toolset>gcc-4.4:<cflags>-fno-exceptions
|
||||
<toolset>gcc-4.5:<cflags>-fno-exceptions
|
||||
<toolset>gcc-4.6:<cflags>-fno-exceptions
|
||||
<toolset>gcc-4.7:<cflags>-fno-exceptions
|
||||
<toolset>gcc-4.3:<cxxflags>-fno-exceptions
|
||||
<toolset>gcc-4.4:<cxxflags>-fno-exceptions
|
||||
<toolset>gcc-4.5:<cxxflags>-fno-exceptions
|
||||
<toolset>gcc-4.6:<cxxflags>-fno-exceptions
|
||||
<toolset>gcc-4.7:<cxxflags>-fno-exceptions
|
||||
<toolset>gcc-4.8:<cxxflags>-fno-exceptions
|
||||
<toolset>clang:<cxxflags>-fno-exceptions
|
||||
]
|
||||
[ run lexical_cast_iterator_range_test.cpp ]
|
||||
[ run lexical_cast_arrays_test.cpp ]
|
||||
|
||||
@@ -68,6 +68,7 @@ void test_conversion_from_to_uintmax_t();
|
||||
void test_conversion_from_to_longlong();
|
||||
void test_conversion_from_to_ulonglong();
|
||||
#endif
|
||||
void test_integral_conversions_on_min_max();
|
||||
|
||||
|
||||
unit_test::test_suite *init_unit_test_suite(int, char *[])
|
||||
@@ -87,6 +88,7 @@ unit_test::test_suite *init_unit_test_suite(int, char *[])
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong));
|
||||
#endif
|
||||
suite->add(BOOST_TEST_CASE(&test_integral_conversions_on_min_max));
|
||||
|
||||
return suite;
|
||||
}
|
||||
@@ -230,7 +232,7 @@ void test_conversion_from_integral_to_string(CharT)
|
||||
|
||||
// Test values around 100, 1000, 10000, ...
|
||||
T ten_power = 100;
|
||||
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
|
||||
for(int e = 2; e < limits::digits10; ++e, ten_power *= 10)
|
||||
{
|
||||
// ten_power + 100 probably never overflows
|
||||
for(t = ten_power - 100; t != ten_power + 100; ++t)
|
||||
@@ -327,7 +329,7 @@ void test_conversion_from_string_to_integral(CharT)
|
||||
|
||||
// Test values around 100, 1000, 10000, ...
|
||||
T ten_power = 100;
|
||||
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
|
||||
for(int e = 2; e < limits::digits10; ++e, ten_power *= 10)
|
||||
{
|
||||
// ten_power + 100 probably never overflows
|
||||
for(t = ten_power - 100; t != ten_power + 100; ++t)
|
||||
@@ -534,6 +536,19 @@ void test_conversion_from_to_ulonglong()
|
||||
|
||||
#endif
|
||||
|
||||
void test_integral_conversions_on_min_max()
|
||||
{
|
||||
typedef std::numeric_limits<int> int_limits;
|
||||
typedef std::numeric_limits<unsigned int> uint_limits;
|
||||
|
||||
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((uint_limits::max)()), (uint_limits::max)());
|
||||
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((uint_limits::min)()), (uint_limits::min)());
|
||||
|
||||
BOOST_CHECK_EQUAL(lexical_cast<int>((int_limits::max)()), (int_limits::max)());
|
||||
BOOST_CHECK_EQUAL(lexical_cast<int>((uint_limits::min)()), static_cast<int>((uint_limits::min)()));
|
||||
|
||||
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((int_limits::max)()), static_cast<unsigned int>((int_limits::max)()));
|
||||
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((int_limits::min)()), static_cast<unsigned int>((int_limits::min)()));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user