| Index: webrtc/base/optional_unittest.cc
 | 
| diff --git a/webrtc/base/optional_unittest.cc b/webrtc/base/optional_unittest.cc
 | 
| index 65070fabb03f2ed0383d64a3aa70f279188e5c14..cc9d2f91643a53aac1a2d5dde7835c7d30b6e7be 100644
 | 
| --- a/webrtc/base/optional_unittest.cc
 | 
| +++ b/webrtc/base/optional_unittest.cc
 | 
| @@ -21,6 +21,34 @@ namespace rtc {
 | 
|  
 | 
|  namespace {
 | 
|  
 | 
| +struct MyUnprintableType {
 | 
| +  int value;
 | 
| +};
 | 
| +
 | 
| +struct MyPrintableType {
 | 
| +  int value;
 | 
| +};
 | 
| +
 | 
| +struct MyOstreamPrintableType {
 | 
| +  int value;
 | 
| +};
 | 
| +
 | 
| +void PrintTo(const MyPrintableType& mpt, std::ostream* os) {
 | 
| +  *os << "The value is " << mpt.value;
 | 
| +}
 | 
| +
 | 
| +std::ostream& operator<<(std::ostream& os,
 | 
| +                         const MyPrintableType& mpt) {
 | 
| +  os << mpt.value;
 | 
| +  return os;
 | 
| +}
 | 
| +
 | 
| +std::ostream& operator<<(std::ostream& os,
 | 
| +                         const MyOstreamPrintableType& mpt) {
 | 
| +  os << mpt.value;
 | 
| +  return os;
 | 
| +}
 | 
| +
 | 
|  // Class whose instances logs various method calls (constructor, destructor,
 | 
|  // etc.). Each instance has a unique ID (a simple global sequence number) and
 | 
|  // an origin ID. When a copy is made, the new object gets a fresh ID but copies
 | 
| @@ -740,4 +768,32 @@ TEST(OptionalTest, TestMoveValue) {
 | 
|        *log);
 | 
|  }
 | 
|  
 | 
| +TEST(OptionalTest, TestPrintTo) {
 | 
| +  constexpr char kEmptyOptionalMessage[] = "<empty optional>";
 | 
| +  const Optional<MyUnprintableType> empty_unprintable;
 | 
| +  const Optional<MyPrintableType> empty_printable;
 | 
| +  const Optional<MyOstreamPrintableType> empty_ostream_printable;
 | 
| +  EXPECT_EQ(kEmptyOptionalMessage, ::testing::PrintToString(empty_unprintable));
 | 
| +  EXPECT_EQ(kEmptyOptionalMessage, ::testing::PrintToString(empty_printable));
 | 
| +  EXPECT_EQ(kEmptyOptionalMessage,
 | 
| +            ::testing::PrintToString(empty_ostream_printable));
 | 
| +  EXPECT_NE("1", ::testing::PrintToString(Optional<MyUnprintableType>({1})));
 | 
| +  EXPECT_NE("1", ::testing::PrintToString(Optional<MyPrintableType>({1})));
 | 
| +  EXPECT_EQ("The value is 1",
 | 
| +            ::testing::PrintToString(Optional<MyPrintableType>({1})));
 | 
| +  EXPECT_EQ("1",
 | 
| +            ::testing::PrintToString(Optional<MyOstreamPrintableType>({1})));
 | 
| +}
 | 
| +
 | 
| +void UnusedFunctionWorkaround() {
 | 
| +  // These are here to ensure we don't get warnings about ostream and PrintTo
 | 
| +  // for MyPrintableType never getting called.
 | 
| +  const MyPrintableType dont_warn{17};
 | 
| +  const MyOstreamPrintableType dont_warn2{18};
 | 
| +  std::stringstream sstr;
 | 
| +  sstr << dont_warn;
 | 
| +  PrintTo(dont_warn, &sstr);
 | 
| +  sstr << dont_warn2;
 | 
| +}
 | 
| +
 | 
|  }  // namespace rtc
 | 
| 
 |