Simplify FMT_VARIADIC.

This commit is contained in:
Victor Zverovich
2014-06-28 11:07:43 -07:00
parent 360bfbdd50
commit 2f6dddd6fd
3 changed files with 71 additions and 66 deletions

View File

@@ -1676,3 +1676,18 @@ TEST(FormatTest, VariadicMacro) {
EXPECT_EQ("42 abc", test(42, " {}", "abc"));
EXPECT_EQ("42 abc 1.2", test(42, " {} {}", "abc", 1.2));
}
std::string FormatError(int error_code, const char *format,
const fmt::ArgList &args) {
fmt::Writer w;
w.format("Error {}: ", error_code);
w.format(format, args);
return w.str();
}
FMT_VARIADIC(std::string, FormatError, int, const char *)
TEST(FormatTest, FormatError) {
EXPECT_EQ("Error 42: something happened",
FormatError(42, "{} happened", "something"));
}

View File

@@ -59,9 +59,9 @@ int result;
}
MAKE_TEST(TestFunc)
FMT_WRAP(TestFunc, const char *, 1)
FMT_WRAP1(TestFunc, const char *, 1)
TEST(UtilTest, Template) {
TEST(UtilTest, Wrap1) {
result = 0;
TestFunc("", 42);
EXPECT_EQ(42, result);