Workaround a bug in formatting long double in MinGW, take 3

This commit is contained in:
vitaut 2015-05-07 08:17:30 -07:00
parent 3e379829a0
commit 85b985e9f2

View File

@ -84,7 +84,7 @@ void std_format(const T &value, std::basic_string<Char> &result) {
// Workaround a bug in formatting long double in MinGW. // Workaround a bug in formatting long double in MinGW.
void std_format(long double value, std::string &result) { void std_format(long double value, std::string &result) {
char buffer[100]; char buffer[100];
snprintf(buffer, sizeof(buffer), "%Lg", value); safe_sprintf(buffer, "%Lg", value);
result = buffer; result = buffer;
} }
#endif #endif
@ -96,7 +96,7 @@ template <typename Char, typename T>
std::basic_string<Char> actual = std::basic_string<Char> actual =
(fmt::BasicMemoryWriter<Char>() << value).str(); (fmt::BasicMemoryWriter<Char>() << value).str();
std::basic_string<Char> expected; std::basic_string<Char> expected;
std_format<Char>(value, expected); std_format(value, expected);
if (expected == actual) if (expected == actual)
return ::testing::AssertionSuccess(); return ::testing::AssertionSuccess();
return ::testing::AssertionFailure() return ::testing::AssertionFailure()