diff options
Diffstat (limited to 'absl/strings/str_cat_test.cc')
-rw-r--r-- | absl/strings/str_cat_test.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/absl/strings/str_cat_test.cc b/absl/strings/str_cat_test.cc index 69df2502..868b9bce 100644 --- a/absl/strings/str_cat_test.cc +++ b/absl/strings/str_cat_test.cc @@ -612,4 +612,24 @@ TEST(Numbers, TestFunctionsMovedOverFromNumbersMain) { TestFastPrints(); } +struct PointStringify { + template <typename FormatSink> + friend void AbslStringify(FormatSink& sink, const PointStringify& p) { + sink.Append("("); + sink.Append(absl::StrCat(p.x)); + sink.Append(", "); + sink.Append(absl::StrCat(p.y)); + sink.Append(")"); + } + + double x = 10.0; + double y = 20.0; +}; + +TEST(StrCat, AbslStringifyExample) { + PointStringify p; + EXPECT_EQ(absl::StrCat(p), "(10, 20)"); + EXPECT_EQ(absl::StrCat("a ", p, " z"), "a (10, 20) z"); +} + } // namespace |