From 639de21757e10f2b080a62ca0761fdb3b5466c35 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 6 Dec 2018 10:12:42 -0800 Subject: [PATCH] Workaround more MSVC bugs --- test/printf-test.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/printf-test.cc b/test/printf-test.cc index c1f945a0..cc62b912 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -32,17 +32,21 @@ static std::wstring make_positional(fmt::wstring_view format) { return s; } -#define EXPECT_PRINTF(expected_output, format, arg) \ - EXPECT_EQ(expected_output, fmt::sprintf(format, arg)) \ - << "format: " << format; \ - EXPECT_EQ(expected_output, fmt::sprintf(make_positional(format), arg)) - // A wrapper around fmt::sprintf to workaround bogus warnings about invalid // format strings in MSVC. -template +template std::string test_sprintf(fmt::string_view format, const Args &... args) { return fmt::sprintf(format, args...); } +template +std::wstring test_sprintf(fmt::wstring_view format, const Args &... args) { + return fmt::sprintf(format, args...); +} + +#define EXPECT_PRINTF(expected_output, format, arg) \ + EXPECT_EQ(expected_output, test_sprintf(format, arg)) \ + << "format: " << format; \ + EXPECT_EQ(expected_output, fmt::sprintf(make_positional(format), arg)) TEST(PrintfTest, NoArgs) { EXPECT_EQ("test", test_sprintf("test"));