Commit 6038c852 authored by Victor Zverovich's avatar Victor Zverovich

format_test -> format-test. Add support for wide char to BasicWriter.

parent 1cc61329
...@@ -315,10 +315,7 @@ TEST(WriterTest, WriteChar) { ...@@ -315,10 +315,7 @@ TEST(WriterTest, WriteChar) {
} }
TEST(WriterTest, WriteWideChar) { TEST(WriterTest, WriteWideChar) {
// TODO CHECK_WRITE_WCHAR(L'a');
//CHECK_WRITE_WCHAR(L'a');
// The following line shouldn't compile:
CHECK_WRITE_CHAR(L'a');
} }
TEST(WriterTest, WriteString) { TEST(WriterTest, WriteString) {
...@@ -1423,6 +1420,20 @@ TEST(StrTest, Convert) { ...@@ -1423,6 +1420,20 @@ TEST(StrTest, Convert) {
EXPECT_EQ("2012-12-9", s); 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);
}
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) { int main(int argc, char **argv) {
#ifdef _WIN32 #ifdef _WIN32
// Disable message boxes on assertion failures. // Disable message boxes on assertion failures.
......
...@@ -700,11 +700,19 @@ class BasicWriter { ...@@ -700,11 +700,19 @@ class BasicWriter {
return *this; return *this;
} }
/**
* Writes a character to the stream.
*/
BasicWriter &operator<<(char value) { BasicWriter &operator<<(char value) {
*GrowBuffer(1) = value; *GrowBuffer(1) = value;
return *this; return *this;
} }
BasicWriter &operator<<(wchar_t value) {
*GrowBuffer(1) = internal::CharTraits<Char>::ConvertWChar(value);
return *this;
}
/** /**
Writes *value* to the stream. Writes *value* to the stream.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment