Added variadic versions for Format that act as a proxy for providing an initialiser list to a BasicFormatter.

Updated the Variadic test to use these new functions and verified that the tests passed.

See https://github.com/vitaut/format/issues/25
This commit is contained in:
jdale88
2014-03-06 20:06:44 +00:00
parent ae96e5bfa6
commit 17d621f86f
2 changed files with 27 additions and 11 deletions
+4 -11
View File
@@ -1485,19 +1485,12 @@ TEST(StrTest, Convert) {
EXPECT_EQ("2012-12-9", s);
}
#if FMT_USE_INITIALIZER_LIST
template<typename... Args>
inline std::string Format(const StringRef &format, const Args & ... args) {
Writer w;
fmt::BasicFormatter<char> f(w, format.c_str(), {args...});
return fmt::str(f);
}
#if FMT_USE_INITIALIZER_LIST && FMT_USE_VARIADIC_TEMPLATES
TEST(FormatTest, Variadic) {
Writer w;
EXPECT_EQ("Hello, world!1", str(Format("Hello, {}!{}", "world", 1)));
EXPECT_EQ("Hello, world!1", Format("Hello, {}!{}", "world", 1));
EXPECT_EQ(L"Hello, world!1", Format(L"Hello, {}!{}", L"world", 1));
}
#endif // FMT_USE_INITIALIZER_LIST
#endif // FMT_USE_INITIALIZER_LIST && FMT_USE_VARIADIC_TEMPLATES
int main(int argc, char **argv) {
#ifdef _WIN32