forked from fmtlib/fmt
Workaround more MSVC bugs
This commit is contained in:
@ -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"));
|
||||||
|
Reference in New Issue
Block a user