Skip to content

Commit

Permalink
streaminfo/mocks: delay filter_state_ dereference (#14612)
Browse files Browse the repository at this point in the history
By dereferencing filter_state_ in the constructor, any test that sets
filter_state_ will dereference an invalid pointer. This may not be a
common use-case, but it came up when writing some microbenchmarks for
a custom filter where I needed to reset the FilterState on each
iteration of the benchmark.

Signed-off-by: Brian Wolfe <[email protected]>
  • Loading branch information
brianwolfe authored Jan 13, 2021
1 parent c151936 commit a4bf246
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/mocks/stream_info/mocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ MockStreamInfo::MockStreamInfo()
ON_CALL(*this, dynamicMetadata()).WillByDefault(ReturnRef(metadata_));
ON_CALL(Const(*this), dynamicMetadata()).WillByDefault(ReturnRef(metadata_));
ON_CALL(*this, filterState()).WillByDefault(ReturnRef(filter_state_));
ON_CALL(Const(*this), filterState()).WillByDefault(ReturnRef(*filter_state_));
ON_CALL(Const(*this), filterState()).WillByDefault(Invoke([this]() -> const FilterState& {
return *filter_state_;
}));
ON_CALL(*this, upstreamFilterState()).WillByDefault(ReturnRef(upstream_filter_state_));
ON_CALL(*this, setUpstreamFilterState(_))
.WillByDefault(Invoke([this](const FilterStateSharedPtr& filter_state) {
Expand Down

0 comments on commit a4bf246

Please sign in to comment.