Skip to content

Commit

Permalink
stream info: add bool string serlalizer (#36451)
Browse files Browse the repository at this point in the history
Change-Id: I2065f5ed863ca4b6b439f00dc39de0dcdbe2eb4c

Commit Message: add missing serializer for bool object. I discovered
this gap while using Wasm `get_property`.
Risk Level: low
Testing: yes

Signed-off-by: Kuat Yessenov <[email protected]>
  • Loading branch information
kyessenov authored Oct 7, 2024
1 parent 0aff211 commit fc10098
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 fc10098

Please sign in to comment.