diff --git a/test/scan-test.cc b/test/scan-test.cc index 803ba0697850..f78d72ca35c5 100644 --- a/test/scan-test.cc +++ b/test/scan-test.cc @@ -97,7 +97,10 @@ template <> struct scanner { auto parse(scan_parse_context& ctx) -> scan_parse_context::iterator { auto it = ctx.begin(), end = ctx.end(); - if (it != end && *it == 'x') hex = true; + if (it != end && *it == 'x') { + hex = true; + ++it; + } if (it != end && *it != '}') throw_format_error("invalid format"); return it; } @@ -111,9 +114,8 @@ template <> struct scanner { } // namespace fmt TEST(scan_test, read_custom) { - auto input = "42"; auto n = num(); - fmt::scan(input, "{:}", n); + fmt::scan("42", "{}", n); EXPECT_EQ(n.value, 42); } diff --git a/test/scan.h b/test/scan.h index 1ef94f41f0a7..54714313d97b 100644 --- a/test/scan.h +++ b/test/scan.h @@ -607,8 +607,9 @@ struct scan_handler { return 0; } - void on_replacement_field(int arg_id, const char*) { + void on_replacement_field(int arg_id, const char* begin) { scan_arg arg = scan_ctx_.arg(arg_id); + if (arg.scan_custom(begin, parse_ctx_, scan_ctx_)) return; auto it = scan_ctx_.begin(); while (it != sentinel() && is_whitespace(*it)) ++it; scan_ctx_.advance_to(arg.visit(default_arg_scanner{it}));