diff --git a/test/custom-formatter-test.cc b/test/custom-formatter-test.cc index 36007caedbdb..a3577c34b7fe 100644 --- a/test/custom-formatter-test.cc +++ b/test/custom-formatter-test.cc @@ -54,3 +54,29 @@ TEST(CustomFormatterTest, Format) { EXPECT_EQ("0.00", custom_format("{:.2f}", -.00001)); } #endif + +#ifdef FMT_USE_STRING_VIEW +struct explicitly_convertible_to_std_string_view { + explicit operator std::string_view() const { return "foo"; } +}; + +namespace fmt { + +template <> +class formatter + : public formatter { + public: + template + auto format(const explicitly_convertible_to_std_string_view& v, + format_context& ctx) { + return formatter::format("'{}'", v, ctx); + } +}; + +} // namespace fmt + +TEST(CustomFormatterTest, FormatExplicitlyConvertibleToStdStringView) { + EXPECT_EQ("'foo'", + fmt::format("{}", explicitly_convertible_to_std_string_view())); +} +#endif