未验证 提交 ba7a3be2 编写于 作者: Q Qiyang Min 提交者: GitHub

Merge pull request #11890 from velconia/fix_ut

Add template specialization of Sprintf
......@@ -83,6 +83,13 @@ void Fprintf(std::ostream& out, const char* fmt, const Args&... args) {
tinyformat::vformat(out, fmt, tinyformat::makeFormatList(args...));
}
template <typename... Args>
std::string Sprintf(const Args&... args) {
std::ostringstream oss;
Fprintf(oss, "");
return oss.str();
}
template <typename... Args>
std::string Sprintf(const char* fmt, const Args&... args) {
std::ostringstream oss;
......
......@@ -27,4 +27,5 @@ TEST(StringPrintf, StringPrintf) {
EXPECT_EQ(std::string("Wednesday, July 27, 14:44"),
paddle::string::Sprintf("%s, %s %d, %.2d:%.2d", weekday, month, day,
hour, min));
EXPECT_EQ(std::string(""), paddle::string::Sprintf());
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册