diff --git a/format_test.cc b/format-test.cc similarity index 99% rename from format_test.cc rename to format-test.cc index 01b66532..32c00351 100644 --- a/format_test.cc +++ b/format-test.cc @@ -315,10 +315,7 @@ TEST(WriterTest, WriteChar) { } TEST(WriterTest, WriteWideChar) { - // TODO - //CHECK_WRITE_WCHAR(L'a'); - // The following line shouldn't compile: - CHECK_WRITE_CHAR(L'a'); + CHECK_WRITE_WCHAR(L'a'); } TEST(WriterTest, WriteString) { @@ -1423,6 +1420,20 @@ TEST(StrTest, Convert) { EXPECT_EQ("2012-12-9", s); } +#if FMT_USE_INITIALIZER_LIST +template +inline std::string Format(const StringRef &format, const Args & ... args) { + Writer w; + fmt::BasicFormatter f(w, format.c_str(), {args...}); + return fmt::str(f); +} + +TEST(FormatTest, Variadic) { + Writer w; + EXPECT_EQ("Hello, world!1", str(Format("Hello, {}!{}", "world", 1))); +} +#endif // FMT_USE_INITIALIZER_LIST + int main(int argc, char **argv) { #ifdef _WIN32 // Disable message boxes on assertion failures. diff --git a/format.h b/format.h index ff65ddd9..c428814d 100644 --- a/format.h +++ b/format.h @@ -700,11 +700,19 @@ class BasicWriter { return *this; } + /** + * Writes a character to the stream. + */ BasicWriter &operator<<(char value) { *GrowBuffer(1) = value; return *this; } + BasicWriter &operator<<(wchar_t value) { + *GrowBuffer(1) = internal::CharTraits::ConvertWChar(value); + return *this; + } + /** Writes *value* to the stream. */