diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index b0a83410..545c1bac 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -187,6 +187,27 @@ inline ::std::ostream& operator<<(::std::ostream& os, return os << "StreamableTemplateInFoo: " << x.value(); } +// A user-defined streamable but recursivly-defined container type in +// a user namespace, it mimics therefore std::filesystem::path or +// boost::filesystem::path. +class PathLike { + public: + struct iterator + { + typedef PathLike value_type; + }; + typedef iterator const_iterator; + + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + + friend + ::std::ostream& operator<<(::std::ostream& os, const PathLike& p) + { + return os << "Streamable-PathLike"; + } +}; + } // namespace foo namespace testing { @@ -1161,6 +1182,13 @@ TEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) { Print(::foo::StreamableTemplateInFoo())); } +// Tests printing a user-defined recursive container type that has a << +// operator. +TEST(PrintStreamableTypeTest, PathLikeInUserNamespace) { + ::foo::PathLike x; + EXPECT_EQ("Streamable-PathLike", Print(x)); +} + // Tests printing user-defined types that have a PrintTo() function. TEST(PrintPrintableTypeTest, InUserNamespace) { EXPECT_EQ("PrintableViaPrintTo: 0",