mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 19:24:48 +02:00
Apply clang-format
This commit is contained in:
@@ -2123,7 +2123,7 @@ template <typename OutputIt, typename UInt, typename Char>
|
|||||||
auto write_int(OutputIt out, UInt value, unsigned prefix,
|
auto write_int(OutputIt out, UInt value, unsigned prefix,
|
||||||
const format_specs<Char>& specs,
|
const format_specs<Char>& specs,
|
||||||
const digit_grouping<Char>& grouping) -> OutputIt {
|
const digit_grouping<Char>& grouping) -> OutputIt {
|
||||||
static_assert(std::is_same<uint64_or_128_t<UInt>, UInt>::value, "");
|
static_assert(std::is_same<uint64_or_128_t<UInt>, UInt>::value, "");
|
||||||
int num_digits = 0;
|
int num_digits = 0;
|
||||||
auto buffer = memory_buffer();
|
auto buffer = memory_buffer();
|
||||||
switch (specs.type) {
|
switch (specs.type) {
|
||||||
@@ -2139,7 +2139,7 @@ auto write_int(OutputIt out, UInt value, unsigned prefix,
|
|||||||
if (specs.alt)
|
if (specs.alt)
|
||||||
prefix_append(prefix, unsigned(upper ? 'X' : 'x') << 8 | '0');
|
prefix_append(prefix, unsigned(upper ? 'X' : 'x') << 8 | '0');
|
||||||
num_digits = count_digits<4>(value);
|
num_digits = count_digits<4>(value);
|
||||||
format_uint<4,Char>(appender(buffer), value, num_digits, upper);
|
format_uint<4, Char>(appender(buffer), value, num_digits, upper);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case presentation_type::bin_lower:
|
case presentation_type::bin_lower:
|
||||||
@@ -2148,7 +2148,7 @@ auto write_int(OutputIt out, UInt value, unsigned prefix,
|
|||||||
if (specs.alt)
|
if (specs.alt)
|
||||||
prefix_append(prefix, unsigned(upper ? 'B' : 'b') << 8 | '0');
|
prefix_append(prefix, unsigned(upper ? 'B' : 'b') << 8 | '0');
|
||||||
num_digits = count_digits<1>(value);
|
num_digits = count_digits<1>(value);
|
||||||
format_uint<1,Char>(appender(buffer), value, num_digits);
|
format_uint<1, Char>(appender(buffer), value, num_digits);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case presentation_type::oct: {
|
case presentation_type::oct: {
|
||||||
@@ -2157,7 +2157,7 @@ auto write_int(OutputIt out, UInt value, unsigned prefix,
|
|||||||
// is not greater than the number of digits.
|
// is not greater than the number of digits.
|
||||||
if (specs.alt && specs.precision <= num_digits && value != 0)
|
if (specs.alt && specs.precision <= num_digits && value != 0)
|
||||||
prefix_append(prefix, '0');
|
prefix_append(prefix, '0');
|
||||||
format_uint<3,Char>(appender(buffer), value, num_digits);
|
format_uint<3, Char>(appender(buffer), value, num_digits);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case presentation_type::chr:
|
case presentation_type::chr:
|
||||||
@@ -2167,11 +2167,11 @@ auto write_int(OutputIt out, UInt value, unsigned prefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned size = (prefix != 0 ? prefix >> 24 : 0) + to_unsigned(num_digits) +
|
unsigned size = (prefix != 0 ? prefix >> 24 : 0) + to_unsigned(num_digits) +
|
||||||
to_unsigned(grouping.count_separators(num_digits));
|
to_unsigned(grouping.count_separators(num_digits));
|
||||||
return write_padded<align::right>(
|
return write_padded<align::right>(
|
||||||
out, specs, size, size, [&](reserve_iterator<OutputIt> it) {
|
out, specs, size, size, [&](reserve_iterator<OutputIt> it) {
|
||||||
for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
|
for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)
|
||||||
*it++ = static_cast<Char>(p & 0xff);
|
*it++ = static_cast<Char>(p & 0xff);
|
||||||
return grouping.apply(it, string_view(buffer.data(), buffer.size()));
|
return grouping.apply(it, string_view(buffer.data(), buffer.size()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1545,12 +1545,10 @@ TEST(format_test, format_cstring) {
|
|||||||
char nonconst[] = "nonconst";
|
char nonconst[] = "nonconst";
|
||||||
EXPECT_EQ("nonconst", fmt::format("{0}", nonconst));
|
EXPECT_EQ("nonconst", fmt::format("{0}", nonconst));
|
||||||
auto nullstr = static_cast<const char*>(nullptr);
|
auto nullstr = static_cast<const char*>(nullptr);
|
||||||
EXPECT_THROW_MSG(
|
EXPECT_THROW_MSG((void)fmt::format("{}", nullstr), format_error,
|
||||||
(void)fmt::format("{}", nullstr),
|
"string pointer is null");
|
||||||
format_error, "string pointer is null");
|
EXPECT_THROW_MSG((void)fmt::format("{:s}", nullstr), format_error,
|
||||||
EXPECT_THROW_MSG(
|
"string pointer is null");
|
||||||
(void)fmt::format("{:s}", nullstr),
|
|
||||||
format_error, "string pointer is null");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_pointer_test(int, double, std::string) {}
|
void function_pointer_test(int, double, std::string) {}
|
||||||
@@ -2298,10 +2296,10 @@ TEST(format_test, format_named_arg_with_locale) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(format_test, format_locale) {
|
TEST(format_test, format_locale) {
|
||||||
auto loc =
|
auto loc = std::locale({}, new fmt::format_facet<std::locale>(","));
|
||||||
std::locale({}, new fmt::format_facet<std::locale>(","));
|
|
||||||
EXPECT_EQ("7,5bc,d15", fmt::format(loc, "{:Lx}", 123456789));
|
EXPECT_EQ("7,5bc,d15", fmt::format(loc, "{:Lx}", 123456789));
|
||||||
EXPECT_EQ("-0b111,010,110,111,100,110,100,010,101", fmt::format(loc, "{:#Lb}", -123456789));
|
EXPECT_EQ("-0b111,010,110,111,100,110,100,010,101",
|
||||||
|
fmt::format(loc, "{:#Lb}", -123456789));
|
||||||
EXPECT_EQ(" 30,071", fmt::format(loc, "{:10Lo}", 12345));
|
EXPECT_EQ(" 30,071", fmt::format(loc, "{:10Lo}", 12345));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user