mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-10 05:10:05 +00:00
Format (un)signed char as integer by default (#217)
This commit is contained in:
parent
9beb01d8e5
commit
7c24973637
4
format.h
4
format.h
@ -1045,8 +1045,8 @@ class MakeValue : public Arg {
|
||||
FMT_MAKE_VALUE(float, double_value, DOUBLE)
|
||||
FMT_MAKE_VALUE(double, double_value, DOUBLE)
|
||||
FMT_MAKE_VALUE(long double, long_double_value, LONG_DOUBLE)
|
||||
FMT_MAKE_VALUE(signed char, int_value, CHAR)
|
||||
FMT_MAKE_VALUE(unsigned char, int_value, CHAR)
|
||||
FMT_MAKE_VALUE(signed char, int_value, INT)
|
||||
FMT_MAKE_VALUE(unsigned char, int_value, UINT)
|
||||
FMT_MAKE_VALUE(char, int_value, CHAR)
|
||||
|
||||
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
|
@ -1324,6 +1324,11 @@ TEST(FormatterTest, FormatChar) {
|
||||
EXPECT_EQ(fmt::format("{:02X}", n), fmt::format("{:02X}", 'x'));
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatUnsignedChar) {
|
||||
EXPECT_EQ("42", format("{}", static_cast<unsigned char>(42)));
|
||||
EXPECT_EQ("42", format("{}", static_cast<uint8_t>(42)));
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatWChar) {
|
||||
EXPECT_EQ(L"a", format(L"{0}", L'a'));
|
||||
// This shouldn't compile:
|
||||
|
@ -471,11 +471,6 @@ TEST(ArgTest, MakeArg) {
|
||||
EXPECT_ARG_(wchar_t, BOOL, bool, int, true);
|
||||
|
||||
// Test char.
|
||||
EXPECT_ARG(CHAR, signed char, 'a');
|
||||
EXPECT_ARG(CHAR, signed char, SCHAR_MIN);
|
||||
EXPECT_ARG(CHAR, signed char, SCHAR_MAX);
|
||||
EXPECT_ARG(CHAR, unsigned char, 'a');
|
||||
EXPECT_ARG(CHAR, unsigned char, UCHAR_MAX );
|
||||
EXPECT_ARG(CHAR, char, 'a');
|
||||
EXPECT_ARG(CHAR, char, CHAR_MIN);
|
||||
EXPECT_ARG(CHAR, char, CHAR_MAX);
|
||||
@ -485,6 +480,13 @@ TEST(ArgTest, MakeArg) {
|
||||
EXPECT_ARGW(CHAR, wchar_t, WCHAR_MIN);
|
||||
EXPECT_ARGW(CHAR, wchar_t, WCHAR_MAX);
|
||||
|
||||
// Test signed/unsigned char.
|
||||
EXPECT_ARG(INT, signed char, 42);
|
||||
EXPECT_ARG(INT, signed char, SCHAR_MIN);
|
||||
EXPECT_ARG(INT, signed char, SCHAR_MAX);
|
||||
EXPECT_ARG(UINT, unsigned char, 42);
|
||||
EXPECT_ARG(UINT, unsigned char, UCHAR_MAX );
|
||||
|
||||
// Test short.
|
||||
EXPECT_ARG(INT, short, 42);
|
||||
EXPECT_ARG(INT, short, SHRT_MIN);
|
||||
|
Loading…
Reference in New Issue
Block a user