Support signed char and unsigned char strings

This commit is contained in:
Victor Zverovich 2014-09-30 08:15:56 -07:00
parent 98a25ec7cb
commit 74dc571ba0
2 changed files with 18 additions and 0 deletions

View File

@ -651,6 +651,8 @@ struct Value {
long double long_double_value;
const void *pointer;
StringValue<char> string;
StringValue<signed char> sstring;
StringValue<unsigned char> ustring;
StringValue<wchar_t> wstring;
CustomValue custom;
};
@ -758,6 +760,8 @@ public:
FMT_MAKE_VALUE(char *, string.value, CSTRING)
FMT_MAKE_VALUE(const char *, string.value, CSTRING)
FMT_MAKE_VALUE(const signed char *, sstring.value, CSTRING)
FMT_MAKE_VALUE(const unsigned char *, ustring.value, CSTRING)
FMT_MAKE_STR_VALUE(const std::string &, STRING)
FMT_MAKE_STR_VALUE(StringRef, STRING)

View File

@ -1170,6 +1170,20 @@ TEST(FormatterTest, FormatCString) {
FormatError, "string pointer is null");
}
TEST(FormatterTest, FormatSCharString) {
signed char str[] = "test";
EXPECT_EQ("test", format("{0:s}", str));
const signed char *const_str = str;
EXPECT_EQ("test", format("{0:s}", const_str));
}
TEST(FormatterTest, FormatUCharString) {
unsigned char str[] = "test";
EXPECT_EQ("test", format("{0:s}", str));
const unsigned char *const_str = str;
EXPECT_EQ("test", format("{0:s}", const_str));
}
TEST(FormatterTest, FormatPointer) {
check_unknown_types(reinterpret_cast<void*>(0x1234), "p", "pointer");
EXPECT_EQ("0x0", format("{0}", reinterpret_cast<void*>(0)));