Test formatting of an object with templated conversion to string-like

This commit is contained in:
Victor Zverovich 2018-07-18 16:24:46 -07:00
parent 73bed45b7a
commit 50584f42b4

View File

@ -1102,6 +1102,18 @@ struct explicitly_convertible_to_string_view {
TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) { TEST(FormatterTest, FormatExplicitlyConvertibleToStringView) {
EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_view())); EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_view()));
} }
struct explicitly_convertible_to_string_like {
template <
typename String,
typename = typename std::enable_if<
std::is_constructible<String, const char*, std::size_t>::value>::type>
explicit operator String() const { return String("foo", 3u); }
};
TEST(FormatterTest, FormatExplicitlyConvertibleToStringLike) {
EXPECT_EQ("foo", format("{}", explicitly_convertible_to_string_like()));
}
#endif #endif
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE