mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-27 06:35:37 +00:00
Support signed char and unsigned char strings
This commit is contained in:
parent
98a25ec7cb
commit
74dc571ba0
4
format.h
4
format.h
@ -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)
|
||||
|
||||
|
@ -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)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user