|
37 | 37 | #include <cstring>
|
38 | 38 | #include <deque>
|
39 | 39 | #include <forward_list>
|
| 40 | +#include <functional> |
40 | 41 | #include <limits>
|
41 | 42 | #include <list>
|
42 | 43 | #include <map>
|
@@ -193,6 +194,11 @@ OutputStream& operator<<(OutputStream& os,
|
193 | 194 | return os;
|
194 | 195 | }
|
195 | 196 |
|
| 197 | +struct StreamableInLocal {}; |
| 198 | +void operator<<(::std::ostream& os, const StreamableInLocal& /* x */) { |
| 199 | + os << "StreamableInLocal"; |
| 200 | +} |
| 201 | + |
196 | 202 | // A user-defined streamable but recursively-defined container type in
|
197 | 203 | // a user namespace, it mimics therefore std::filesystem::path or
|
198 | 204 | // boost::filesystem::path.
|
@@ -1604,6 +1610,23 @@ TEST(PrintToStringTest, ContainsNonLatin) {
|
1604 | 1610 | "\n As Text: \"From ä — ẑ\"");
|
1605 | 1611 | }
|
1606 | 1612 |
|
| 1613 | +TEST(PrintToStringTest, PrintStreamableInLocal) { |
| 1614 | + EXPECT_STREQ("StreamableInLocal", |
| 1615 | + PrintToString(foo::StreamableInLocal()).c_str()); |
| 1616 | +} |
| 1617 | + |
| 1618 | +TEST(PrintToStringTest, PrintReferenceToStreamableInLocal) { |
| 1619 | + foo::StreamableInLocal s; |
| 1620 | + std::reference_wrapper<foo::StreamableInLocal> r(s); |
| 1621 | + EXPECT_STREQ("StreamableInLocal", PrintToString(r).c_str()); |
| 1622 | +} |
| 1623 | + |
| 1624 | +TEST(PrintToStringTest, PrintReferenceToStreamableInGlobal) { |
| 1625 | + StreamableInGlobal s; |
| 1626 | + std::reference_wrapper<StreamableInGlobal> r(s); |
| 1627 | + EXPECT_STREQ("StreamableInGlobal", PrintToString(r).c_str()); |
| 1628 | +} |
| 1629 | + |
1607 | 1630 | TEST(IsValidUTF8Test, IllFormedUTF8) {
|
1608 | 1631 | // The following test strings are ill-formed UTF-8 and are printed
|
1609 | 1632 | // as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is
|
|
0 commit comments