If std::swprintf is broken, disable relevant test and warn about it

This commit is contained in:
vitaut 2015-05-08 07:57:43 -07:00
parent 85b985e9f2
commit 3e03934d15

View File

@ -87,6 +87,11 @@ void std_format(long double value, std::string &result) {
safe_sprintf(buffer, "%Lg", value);
result = buffer;
}
void std_format(long double value, std::wstring &result) {
wchar_t buffer[100];
swprintf(buffer, L"%Lg", value);
result = buffer;
}
#endif
// Checks if writing value to BasicWriter<Char> produces the same result
@ -284,7 +289,13 @@ TEST(WriterTest, WriteDouble) {
TEST(WriterTest, WriteLongDouble) {
CHECK_WRITE(4.2l);
CHECK_WRITE(-4.2l);
CHECK_WRITE_CHAR(-4.2l);
std::wstring str;
std_format(4.2l, str);
if (str[0] != '-')
CHECK_WRITE_WCHAR(-4.2l);
else
fmt::print("warning: long double formatting with std::swprintf is broken");
CHECK_WRITE(std::numeric_limits<long double>::min());
CHECK_WRITE(std::numeric_limits<long double>::max());
}