From 3e03934d15dd1c135e1a3766c6906e7c84d111b5 Mon Sep 17 00:00:00 2001 From: vitaut Date: Fri, 8 May 2015 07:57:43 -0700 Subject: [PATCH] If std::swprintf is broken, disable relevant test and warn about it --- test/format-test.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/format-test.cc b/test/format-test.cc index ac908b8c..4f6fc5fe 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -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 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::min()); CHECK_WRITE(std::numeric_limits::max()); }