Add more debug

This commit is contained in:
Krystian Stasiowski
2020-02-22 21:44:34 -05:00
parent cd70147c7d
commit c0b78c7698
2 changed files with 47 additions and 45 deletions

View File

@ -542,8 +542,10 @@ to_static_wstring_float_impl(long double value) noexcept
wchar_t buffer[N + 1]; wchar_t buffer[N + 1];
// swprintf returns a negative number if it can't // swprintf returns a negative number if it can't
// fit all the characters in the buffer // fit all the characters in the buffer
std::cout << "trying swprintf\n";
if (std::swprintf(buffer, N + 1, L"%Lf", value) < 0) if (std::swprintf(buffer, N + 1, L"%Lf", value) < 0)
{ {
std::cout << "swprintf < 0\n";
// the + 4 is for the decimal, 'e', // the + 4 is for the decimal, 'e',
// its sign, and the sign of the integral portion // its sign, and the sign of the integral portion
const int reserved_count = const int reserved_count =

View File

@ -3680,66 +3680,66 @@ testGeneral()
void void
testToStaticString() testToStaticString()
{ {
BOOST_TEST(testTS(0, "0", L"0", true)); //BOOST_TEST(testTS(0, "0", L"0", true));
BOOST_TEST(testTS(0u, "0", L"0", true)); //BOOST_TEST(testTS(0u, "0", L"0", true));
BOOST_TEST(testTS(0xffff, "65535", L"65535", true)); //BOOST_TEST(testTS(0xffff, "65535", L"65535", true));
BOOST_TEST(testTS(0x10000, "65536", L"65536", true)); //BOOST_TEST(testTS(0x10000, "65536", L"65536", true));
BOOST_TEST(testTS(0xffffffff, "4294967295", L"4294967295", true)); //BOOST_TEST(testTS(0xffffffff, "4294967295", L"4294967295", true));
BOOST_TEST(testTS(-65535, "-65535", L"-65535", true)); //BOOST_TEST(testTS(-65535, "-65535", L"-65535", true));
BOOST_TEST(testTS(-65536, "-65536", L"-65536", true)); //BOOST_TEST(testTS(-65536, "-65536", L"-65536", true));
BOOST_TEST(testTS(-4294967295ll, "-4294967295", L"-4294967295", true)); //BOOST_TEST(testTS(-4294967295ll, "-4294967295", L"-4294967295", true));
BOOST_TEST(testTS(1, "1", L"1", true)); //BOOST_TEST(testTS(1, "1", L"1", true));
BOOST_TEST(testTS(-1, "-1", L"-1", true)); //BOOST_TEST(testTS(-1, "-1", L"-1", true));
BOOST_TEST(testTS(0.1)); //BOOST_TEST(testTS(0.1));
BOOST_TEST(testTS(0.0000001)); //BOOST_TEST(testTS(0.0000001));
BOOST_TEST(testTS(-0.0000001)); //BOOST_TEST(testTS(-0.0000001));
BOOST_TEST(testTS(-0.1)); //BOOST_TEST(testTS(-0.1));
BOOST_TEST(testTS(1234567890.0001)); //BOOST_TEST(testTS(1234567890.0001));
BOOST_TEST(testTS(1.123456789012345)); //BOOST_TEST(testTS(1.123456789012345));
BOOST_TEST(testTS(-1234567890.1234)); //BOOST_TEST(testTS(-1234567890.1234));
BOOST_TEST(testTS(-1.123456789012345)); //BOOST_TEST(testTS(-1.123456789012345));
BOOST_TEST(testTS(std::numeric_limits<long long>::max())); //BOOST_TEST(testTS(std::numeric_limits<long long>::max()));
BOOST_TEST(testTS(std::numeric_limits<long long>::min())); //BOOST_TEST(testTS(std::numeric_limits<long long>::min()));
BOOST_TEST(testTS(std::numeric_limits<unsigned long long>::max())); //BOOST_TEST(testTS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTS(std::numeric_limits<unsigned long long>::max())); //BOOST_TEST(testTS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTS(std::numeric_limits<long double>::min())); //BOOST_TEST(testTS(std::numeric_limits<long double>::min()));
BOOST_TEST(testTS(std::numeric_limits<float>::min())); //BOOST_TEST(testTS(std::numeric_limits<float>::min()));
//
// these tests technically are not portable, but they will work //// these tests technically are not portable, but they will work
// 99% of the time. //// 99% of the time.
{ //{
auto str = to_static_string(std::numeric_limits<float>::max()); // auto str = to_static_string(std::numeric_limits<float>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != // BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == "infinity" || str == "inf"); // static_string<0>::npos || str == "infinity" || str == "inf");
} //}
{ //{
auto str = to_static_string(std::numeric_limits<double>::max()); // auto str = to_static_string(std::numeric_limits<double>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != // BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == "infinity" || str == "inf"); // static_string<0>::npos || str == "infinity" || str == "inf");
} //}
{ //{
auto str = to_static_string(std::numeric_limits<long double>::max()); // auto str = to_static_string(std::numeric_limits<long double>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != // BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == "infinity" || str == "inf"); // static_string<0>::npos || str == "infinity" || str == "inf");
} //}
{ {
auto str = to_static_wstring(std::numeric_limits<float>::max()); auto str = to_static_wstring(std::numeric_limits<float>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == L"infinity" || str == L"inf"); static_string<0>::npos || str == L"infinity" || str == L"inf");
std::wcout << str; std::wcout << str << '\n';
} }
{ {
auto str = to_static_wstring(std::numeric_limits<double>::max()); auto str = to_static_wstring(std::numeric_limits<double>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == L"infinity" || str == L"inf"); static_string<0>::npos || str == L"infinity" || str == L"inf");
std::wcout << str; std::wcout << str << '\n';
} }
{ {
auto str = to_static_wstring(std::numeric_limits<long double>::max()); auto str = to_static_wstring(std::numeric_limits<long double>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == L"infinity" || str == L"inf"); static_string<0>::npos || str == L"infinity" || str == L"inf");
std::wcout << str; std::wcout << str << '\n';
} }
} }