format_test -> format-test. Add support for wide char to BasicWriter.
This commit is contained in:
parent
1cc61329ae
commit
6038c85231
@ -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<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) {
|
||||
#ifdef _WIN32
|
||||
// Disable message boxes on assertion failures.
|
8
format.h
8
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<Char>::ConvertWChar(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
Writes *value* to the stream.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user