From dfac111ddf3e66214f6eaccfbd9e57419975c37c Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Fri, 4 Oct 2024 21:30:03 +0000 Subject: [PATCH] stream info: add bool string serlalizer Change-Id: I2065f5ed863ca4b6b439f00dc39de0dcdbe2eb4c Signed-off-by: Kuat Yessenov --- source/common/stream_info/bool_accessor_impl.h | 4 ++++ test/common/stream_info/bool_accessor_impl_test.cc | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/source/common/stream_info/bool_accessor_impl.h b/source/common/stream_info/bool_accessor_impl.h index 868bfefab953..8de1563fae48 100644 --- a/source/common/stream_info/bool_accessor_impl.h +++ b/source/common/stream_info/bool_accessor_impl.h @@ -19,6 +19,10 @@ class BoolAccessorImpl : public BoolAccessor { return message; } + absl::optional serializeAsString() const override { + return value_ ? "true" : "false"; + } + // From BoolAccessor. bool value() const override { return value_; } diff --git a/test/common/stream_info/bool_accessor_impl_test.cc b/test/common/stream_info/bool_accessor_impl_test.cc index dcc8c5ccc9f6..4f0845f05e65 100644 --- a/test/common/stream_info/bool_accessor_impl_test.cc +++ b/test/common/stream_info/bool_accessor_impl_test.cc @@ -22,6 +22,12 @@ TEST(BoolAccessorImplTest, TestProto) { EXPECT_NE(nullptr, message); } +TEST(BoolAccessorImplTest, TestString) { + BoolAccessorImpl accessor(true); + auto str = accessor.serializeAsString(); + EXPECT_EQ("true", str); +} + } // namespace } // namespace StreamInfo } // namespace Envoy