Skip to content

Commit

Permalink
stream info: add bool string serlalizer
Browse files Browse the repository at this point in the history
Change-Id: I2065f5ed863ca4b6b439f00dc39de0dcdbe2eb4c
Signed-off-by: Kuat Yessenov <[email protected]>
  • Loading branch information
kyessenov committed Oct 4, 2024
1 parent 42068a5 commit dfac111
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/common/stream_info/bool_accessor_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class BoolAccessorImpl : public BoolAccessor {
return message;
}

absl::optional<std::string> serializeAsString() const override {
return value_ ? "true" : "false";
}

// From BoolAccessor.
bool value() const override { return value_; }

Expand Down
6 changes: 6 additions & 0 deletions test/common/stream_info/bool_accessor_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit dfac111

Please sign in to comment.