Commit 639de217 authored by Victor Zverovich's avatar Victor Zverovich

Workaround more MSVC bugs

parent 3242ddf7
...@@ -32,17 +32,21 @@ static std::wstring make_positional(fmt::wstring_view format) { ...@@ -32,17 +32,21 @@ static std::wstring make_positional(fmt::wstring_view format) {
return s; 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 // A wrapper around fmt::sprintf to workaround bogus warnings about invalid
// format strings in MSVC. // format strings in MSVC.
template <typename ...Args> template <typename... Args>
std::string test_sprintf(fmt::string_view format, const Args &... args) { std::string test_sprintf(fmt::string_view format, const Args &... args) {
return fmt::sprintf(format, args...); return fmt::sprintf(format, args...);
} }
template <typename... Args>
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) { TEST(PrintfTest, NoArgs) {
EXPECT_EQ("test", test_sprintf("test")); EXPECT_EQ("test", test_sprintf("test"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment