Teach googletest how to pretty-print WideString

Add a test-only PrintTo() function for WideString.

Change-Id: I923ba171e12bebc1791d37bfaf5ade06bde7db66
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/106710
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: K. Moon <kmoon@chromium.org>
diff --git a/core/fxcrt/string_test_support.cpp b/core/fxcrt/string_test_support.cpp
index 254e37a..cbb1220 100644
--- a/core/fxcrt/string_test_support.cpp
+++ b/core/fxcrt/string_test_support.cpp
@@ -5,6 +5,7 @@
 #include <ostream>
 
 #include "core/fxcrt/bytestring.h"
+#include "core/fxcrt/widestring.h"
 
 namespace fxcrt {
 
@@ -12,4 +13,8 @@
   *os << str;
 }
 
+void PrintTo(const WideString& str, std::ostream* os) {
+  *os << str;
+}
+
 }  // namespace fxcrt
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index cf9edd3..ff291f8 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -304,6 +304,13 @@
 std::wostream& operator<<(std::wostream& os, WideStringView str);
 std::ostream& operator<<(std::ostream& os, WideStringView str);
 
+// This is declared here for use in gtest-based tests but is defined in a test
+// support target. This should not be used in production code. Just use
+// operator<< from above instead.
+// In some cases, gtest will automatically use operator<< as well, but in this
+// case, it needs PrintTo() because WideString looks like a container to gtest.
+void PrintTo(const WideString& str, std::ostream* os);
+
 }  // namespace fxcrt
 
 using WideString = fxcrt::WideString;