diff options
| author | Christoph Berg <myon@debian.org> | 2020-05-11 22:17:58 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-05-11 22:17:58 +0200 |
| commit | 32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (patch) | |
| tree | c6e107c1ee4d70610e43a7912e57c720334a08c7 /boost/libs/math/test/test_lexical_cast.cpp | |
| parent | 08299e8b2bf50ba90daf570f57def529dd29d6e7 (diff) | |
New upstream version 2.2.0~rc1+repackupstream/2.2.0_rc1+repack
Diffstat (limited to 'boost/libs/math/test/test_lexical_cast.cpp')
| -rw-r--r-- | boost/libs/math/test/test_lexical_cast.cpp | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/boost/libs/math/test/test_lexical_cast.cpp b/boost/libs/math/test/test_lexical_cast.cpp deleted file mode 100644 index 72eb9854..00000000 --- a/boost/libs/math/test/test_lexical_cast.cpp +++ /dev/null @@ -1,122 +0,0 @@ - -// Copyright (c) 2006 Johan Rade - -// Copyright (c) 2011 Paul A. Bristow incorporated Boost.Math - -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt -// or copy at http://www.boost.org/LICENSE_1_0.txt) - -//#ifdef _MSC_VER -//# pragma warning(disable : 4127 4511 4512 4701 4702) -//#endif - -#define BOOST_TEST_MAIN - -#include <limits> -#include <locale> -#include <string> -#include <boost/lexical_cast.hpp> -#include <boost/test/auto_unit_test.hpp> - -#include <boost/math/special_functions/nonfinite_num_facets.hpp> -#include <boost/math/special_functions/sign.hpp> -#include <boost/math/special_functions/fpclassify.hpp> -#include "almost_equal.ipp" -#include "s_.ipp" - -namespace { - -// the anonymous namespace resolves ambiguities on platforms -// with fpclassify etc functions at global scope - -using boost::lexical_cast; - -using namespace boost::math; -using boost::math::signbit; -using boost::math::changesign; -using boost::math::isnan; - -//------------------------------------------------------------------------------ - -template<class CharType, class ValType> void lexical_cast_test_impl(); - -BOOST_AUTO_TEST_CASE(lexical_cast_test) -{ - lexical_cast_test_impl<char, float>(); - lexical_cast_test_impl<char, double>(); - lexical_cast_test_impl<char, long double>(); - lexical_cast_test_impl<wchar_t, float>(); - lexical_cast_test_impl<wchar_t, double>(); - lexical_cast_test_impl<wchar_t, long double>(); -} - -template<class CharType, class ValType> void lexical_cast_test_impl() -{ - if((std::numeric_limits<ValType>::has_infinity == 0) || (std::numeric_limits<ValType>::infinity() == 0)) - return; - if((std::numeric_limits<ValType>::has_quiet_NaN == 0) || (std::numeric_limits<ValType>::quiet_NaN() == 0)) - return; - - std::locale old_locale; - std::locale tmp_locale(old_locale, - new nonfinite_num_put<CharType>(signed_zero)); - std::locale new_locale(tmp_locale, new nonfinite_num_get<CharType>); - std::locale::global(new_locale); - - ValType a1 = static_cast<ValType>(0); - ValType a2 = static_cast<ValType>(13); - ValType a3 = std::numeric_limits<ValType>::infinity(); - ValType a4 = std::numeric_limits<ValType>::quiet_NaN(); - ValType a5 = std::numeric_limits<ValType>::signaling_NaN(); - ValType a6 = (changesign)(static_cast<ValType>(0)); - ValType a7 = static_cast<ValType>(-57); - ValType a8 = -std::numeric_limits<ValType>::infinity(); - ValType a9 = (changesign)(std::numeric_limits<ValType>::quiet_NaN()); // -NaN - ValType a10 = (changesign)(std::numeric_limits<ValType>::signaling_NaN()); // -NaN - - std::basic_string<CharType> s1 = S_("0"); - std::basic_string<CharType> s2 = S_("13"); - std::basic_string<CharType> s3 = S_("inf"); - std::basic_string<CharType> s4 = S_("nan"); - std::basic_string<CharType> s5 = S_("nan"); - std::basic_string<CharType> s6 = S_("-0"); - std::basic_string<CharType> s7 = S_("-57"); - std::basic_string<CharType> s8 = S_("-inf"); - std::basic_string<CharType> s9 = S_("-nan"); - std::basic_string<CharType> s10 = S_("-nan"); - - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a1) == s1); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a2) == s2); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a3) == s3); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a4) == s4); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a5) == s5); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a6) == s6); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a7) == s7); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a8) == s8); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a9) == s9); - BOOST_CHECK(lexical_cast<std::basic_string<CharType> >(a10) == s10); - - BOOST_CHECK(lexical_cast<ValType>(s1) == a1); - BOOST_CHECK(!(signbit)(lexical_cast<ValType>(s1))); - BOOST_CHECK(lexical_cast<ValType>(s2) == a2); - BOOST_CHECK(lexical_cast<ValType>(s3) == a3); - BOOST_CHECK((isnan)(lexical_cast<ValType>(s4))); - BOOST_CHECK(!(signbit)(lexical_cast<ValType>(s4))); - BOOST_CHECK((isnan)(lexical_cast<ValType>(s5))); - BOOST_CHECK(!(signbit)(lexical_cast<ValType>(s5))); - BOOST_CHECK(lexical_cast<ValType>(a6) == a6); - BOOST_CHECK((signbit)(lexical_cast<ValType>(s6))); - BOOST_CHECK(lexical_cast<ValType>(s7) == a7); - BOOST_CHECK(lexical_cast<ValType>(s8) == a8); - BOOST_CHECK((isnan)(lexical_cast<ValType>(s9))); - BOOST_CHECK((signbit)(lexical_cast<ValType>(s9))); - BOOST_CHECK((isnan)(lexical_cast<ValType>(s10))); - BOOST_CHECK((signbit)(lexical_cast<ValType>(s10))); - - std::locale::global(old_locale); -} - -//------------------------------------------------------------------------------ - -} // anonymous namespace |
