More iterator support
This commit is contained in:
@@ -15,15 +15,13 @@ using fmt::printf_arg_formatter;
|
||||
// A custom argument formatter that doesn't print `-` for floating-point values
|
||||
// rounded to 0.
|
||||
class CustomArgFormatter :
|
||||
public fmt::arg_formatter<
|
||||
fmt::internal::dynamic_range<fmt::internal::buffer>> {
|
||||
public fmt::arg_formatter<fmt::back_insert_range<fmt::internal::buffer>> {
|
||||
public:
|
||||
using range = fmt::internal::dynamic_range<fmt::internal::buffer>;
|
||||
using range = fmt::back_insert_range<fmt::internal::buffer>;
|
||||
using base = fmt::arg_formatter<range>;
|
||||
|
||||
CustomArgFormatter(range r, fmt::basic_context<range> &ctx,
|
||||
fmt::format_specs &s)
|
||||
: base(r, ctx, s) {}
|
||||
CustomArgFormatter(fmt::basic_context<range> &ctx, fmt::format_specs &s)
|
||||
: base(ctx, s) {}
|
||||
|
||||
using base::operator();
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ void std_format(long double value, std::wstring &result) {
|
||||
template <typename Char, typename T>
|
||||
::testing::AssertionResult check_write(const T &value, const char *type) {
|
||||
fmt::basic_memory_buffer<Char> buffer;
|
||||
using range = fmt::internal::dynamic_range<fmt::internal::basic_buffer<Char>>;
|
||||
using range = fmt::back_insert_range<fmt::internal::basic_buffer<Char>>;
|
||||
fmt::basic_writer<range> writer(buffer);
|
||||
writer.write(value);
|
||||
std::basic_string<Char> actual = to_string(buffer);
|
||||
@@ -1481,7 +1481,7 @@ TEST(FormatTest, Enum) {
|
||||
EXPECT_EQ("0", fmt::format("{}", A));
|
||||
}
|
||||
|
||||
using buffer_range = fmt::internal::dynamic_range<fmt::internal::buffer>;
|
||||
using buffer_range = fmt::back_insert_range<fmt::internal::buffer>;
|
||||
|
||||
class mock_arg_formatter :
|
||||
public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
@@ -1492,8 +1492,8 @@ class mock_arg_formatter :
|
||||
using base = fmt::internal::arg_formatter_base<buffer_range>;
|
||||
using range = buffer_range;
|
||||
|
||||
mock_arg_formatter(buffer_range r, fmt::context &, fmt::format_specs &s)
|
||||
: base(r, s) {
|
||||
mock_arg_formatter(fmt::context &ctx, fmt::format_specs &s)
|
||||
: base(fmt::internal::get_container(ctx.begin()), s) {
|
||||
EXPECT_CALL(*this, call(42));
|
||||
}
|
||||
|
||||
@@ -1905,6 +1905,6 @@ TEST(FormatTest, FormatStringErrors) {
|
||||
int, int);
|
||||
}
|
||||
|
||||
TEST(StringTest, ToString) {
|
||||
TEST(FormatTest, ToString) {
|
||||
EXPECT_EQ("42", fmt::to_string(42));
|
||||
}
|
||||
|
||||
@@ -59,17 +59,15 @@ TEST(OStreamTest, Enum) {
|
||||
}
|
||||
|
||||
struct test_arg_formatter : fmt::arg_formatter<fmt::context::range_type> {
|
||||
using base = fmt::arg_formatter<fmt::context::range_type>;
|
||||
test_arg_formatter(fmt::internal::buffer &buf, fmt::context &ctx,
|
||||
fmt::format_specs &s)
|
||||
: base(buf, ctx, s) {}
|
||||
test_arg_formatter(fmt::context &ctx, fmt::format_specs &s)
|
||||
: fmt::arg_formatter<fmt::context::range_type>(ctx, s) {}
|
||||
};
|
||||
|
||||
TEST(OStreamTest, CustomArg) {
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::context ctx(buffer, "", fmt::format_args());
|
||||
fmt::format_specs spec;
|
||||
test_arg_formatter af(buffer, ctx, spec);
|
||||
test_arg_formatter af(ctx, spec);
|
||||
visit(af, fmt::internal::make_arg<fmt::context>(TestEnum()));
|
||||
EXPECT_EQ("TestEnum", std::string(buffer.data(), buffer.size()));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ struct formatter<Test, Char> {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
using range = fmt::internal::dynamic_range<basic_buffer<Char>>;
|
||||
using range = fmt::back_insert_range<basic_buffer<Char>>;
|
||||
|
||||
auto format(Test, basic_context<range> &ctx) -> decltype(ctx.begin()) {
|
||||
const Char *test = "test";
|
||||
@@ -521,7 +521,7 @@ VISIT_TYPE(float, double);
|
||||
#define CHECK_ARG_(Char, expected, value) { \
|
||||
testing::StrictMock<MockVisitor<decltype(expected)>> visitor; \
|
||||
EXPECT_CALL(visitor, visit(expected)); \
|
||||
using range = fmt::internal::dynamic_range<basic_buffer<Char>>; \
|
||||
using range = fmt::back_insert_range<basic_buffer<Char>>; \
|
||||
fmt::visit(visitor, make_arg<fmt::basic_context<range>>(value)); \
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user