diff options
author | 2022-12-02 08:58:00 -0800 | |
---|---|---|
committer | 2022-12-02 08:58:36 -0800 | |
commit | afcb7de0cfe94ad2ec95dfd0380f74a4b972401c (patch) | |
tree | 463f2a6ccbfbe3fead74c7d1f48e815e00d4501f /absl/strings/substitute_test.cc | |
parent | 7cbdff8c13503561a166438e45bc37c5c5d0066b (diff) |
Add AbslStringify support for enum types in Substitute.
PiperOrigin-RevId: 492481345
Change-Id: Ie77656ed334b54930ee852d31e2794a1fc58ce2f
Diffstat (limited to 'absl/strings/substitute_test.cc')
-rw-r--r-- | absl/strings/substitute_test.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/absl/strings/substitute_test.cc b/absl/strings/substitute_test.cc index 9f04545f..9cb37c39 100644 --- a/absl/strings/substitute_test.cc +++ b/absl/strings/substitute_test.cc @@ -253,6 +253,18 @@ TEST(SubstituteTest, Enums) { ScopedEnumUInt16::kEnum1)); } +enum class EnumWithStringify { Many = 0, Choices = 1 }; + +template <typename Sink> +void AbslStringify(Sink& sink, EnumWithStringify e) { + sink.Append(e == EnumWithStringify::Many ? "Many" : "Choices"); +} + +TEST(SubstituteTest, AbslStringifyWithEnum) { + const auto e = EnumWithStringify::Choices; + EXPECT_EQ(absl::Substitute("$0", e), "Choices"); +} + #ifdef GTEST_HAS_DEATH_TEST TEST(SubstituteDeathTest, SubstituteDeath) { |