Escape range items convertible to std::string_view

This commit is contained in:
Victor Zverovich
2021-12-27 09:38:06 -08:00
parent 33ee4cc516
commit 796662a612
2 changed files with 21 additions and 1 deletions
+11
View File
@@ -350,3 +350,14 @@ TEST(ranges_test, escape_string) {
"[\"\\xf4\\x8f\\xbf\\xc0\"]");
}
}
#ifdef FMT_USE_STRING_VIEW
struct convertible_to_string_view {
operator std::string_view() const { return "foo"; }
};
TEST(ranges_test, escape_convertible_to_string_view) {
EXPECT_EQ(fmt::format("{}", std::vector<convertible_to_string_view>(1)),
"[\"foo\"]");
}
#endif // FMT_USE_STRING_VIEW