mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-02 07:01:58 +01:00
Make formatter override implicit conversion to a C string
This commit is contained in:
@@ -264,17 +264,13 @@ struct explicitly_convertible_to_string_like {
|
||||
}
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
explicitly_convertible_to_string_like) {
|
||||
return os << "bar";
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLikeIgnoreInserter) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
|
||||
EXPECT_EQ("bar", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
|
||||
#ifdef FMT_USE_STRING_VIEW
|
||||
@@ -284,17 +280,13 @@ struct explicitly_convertible_to_std_string_view {
|
||||
}
|
||||
};
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringView) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
explicitly_convertible_to_std_string_view) {
|
||||
return os << "bar";
|
||||
}
|
||||
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringViewIgnoreInserter) {
|
||||
EXPECT_EQ("foo",
|
||||
fmt::format("{}", explicitly_convertible_to_std_string_view()));
|
||||
TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringView) {
|
||||
EXPECT_EQ("bar", fmt::format("{}", explicitly_convertible_to_string_like()));
|
||||
}
|
||||
|
||||
#endif // FMT_USE_STRING_VIEW
|
||||
|
||||
Reference in New Issue
Block a user