diff --git a/test/format-test.cc b/test/format-test.cc index f79c4cf0..0d0bb906 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -74,19 +74,18 @@ namespace { // Format value using the standard library. template -std::basic_string std_format(const T &value) { +void std_format(const T &value, std::basic_string &result) { std::basic_ostringstream os; os << value; - return os.str(); + result = os.str(); } #ifdef __MINGW32__ // Workaround a bug in formatting long double in MinGW. -template -std::basic_string std_format(long double value) { +void std_format(long double value, std::string &result) { char buffer[100]; - sprintf_s(buffer, sizeof(buffer), "%Lg", value); - return buffer; + snprintf(buffer, sizeof(buffer), "%Lg", value); + result = buffer; } #endif @@ -96,7 +95,8 @@ template ::testing::AssertionResult check_write(const T &value, const char *type) { std::basic_string actual = (fmt::BasicMemoryWriter() << value).str(); - std::basic_string expected = std_format(value); + std::basic_string expected; + std_format(value, expected); if (expected == actual) return ::testing::AssertionSuccess(); return ::testing::AssertionFailure()