summaryrefslogtreecommitdiffstats
path: root/googletest/test/googletest-message-test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/test/googletest-message-test.cc')
-rw-r--r--googletest/test/googletest-message-test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/googletest/test/googletest-message-test.cc b/googletest/test/googletest-message-test.cc
index 54e9d43..bf1f094 100644
--- a/googletest/test/googletest-message-test.cc
+++ b/googletest/test/googletest-message-test.cc
@@ -36,10 +36,26 @@
#include "gtest/gtest-message.h"
#include "gtest/gtest.h"
+#ifdef GTEST_HAS_ABSL
+#include "absl/strings/str_format.h"
+#endif // GTEST_HAS_ABSL
+
namespace {
using ::testing::Message;
+#ifdef GTEST_HAS_ABSL
+struct AbslStringifiablePoint {
+ template <typename Sink>
+ friend void AbslStringify(Sink& sink, const AbslStringifiablePoint& p) {
+ absl::Format(&sink, "(%d, %d)", p.x, p.y);
+ }
+
+ int x;
+ int y;
+};
+#endif // GTEST_HAS_ABSL
+
// Tests the testing::Message class
// Tests the default constructor.
@@ -128,6 +144,13 @@ TEST(MessageTest, StreamsInt) {
EXPECT_EQ("123", (Message() << 123).GetString());
}
+#ifdef GTEST_HAS_ABSL
+// Tests streaming a type with an AbslStringify definition.
+TEST(MessageTest, StreamsAbslStringify) {
+ EXPECT_EQ("(1, 2)", (Message() << AbslStringifiablePoint{1, 2}).GetString());
+}
+#endif // GTEST_HAS_ABSL
+
// Tests that basic IO manipulators (endl, ends, and flush) can be
// streamed to Message.
TEST(MessageTest, StreamsBasicIoManip) {