forked from fmtlib/fmt
format_test -> format-test. Add support for wide char to BasicWriter.
This commit is contained in:
@@ -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) {
|
|||||||
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.
|
8
format.h
8
format.h
@@ -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.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user