Ovalenti/rox 29399 directional ext i ps jv 2#2142
Open
JoukoVirtanen wants to merge 16 commits intomasterfrom
Open
Ovalenti/rox 29399 directional ext i ps jv 2#2142JoukoVirtanen wants to merge 16 commits intomasterfrom
JoukoVirtanen wants to merge 16 commits intomasterfrom
Conversation
5 tasks
JoukoVirtanen
commented
May 27, 2025
| EXPECT_TRUE(config.ExternalIPsConf().IsEnabled(Direction::BOTH)); | ||
| } | ||
|
|
||
| TEST(CollectorConfigTest, TestIsEnabledIngress) { |
Contributor
Author
There was a problem hiding this comment.
These tests could all be done in one test in a loop.
Molter73
reviewed
May 28, 2025
| public: | ||
| enum Direction { | ||
| NONE = 0, | ||
| NONE = 1 << 2, |
Collaborator
There was a problem hiding this comment.
I think it makes more sense to change IsEnabled like this:
bool IsEnabled(Direction direction) const { return direction != Direction::None && (direction & direction_enabled_) == direction; }On a different note, I don't think IsEnabled(Direction::NONE) is something anyone would write, so I'm not convinced the extra overhead for the check is worth it. Maybe we can do a static check instead?
bool IsEnabled(Direction direction) const {
static_assert(direction != Direction::NONE);
return (direction & direction_enabled_) == direction;
}Or, if a compile time check is not possible, then just use good old assert to make the invariant explicit.
bool IsEnabled(Direction direction) const {
assert(direction != Direction::NONE);
return (direction & direction_enabled_) == direction;
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a problem where
IsEnabled(Direction::NONE)always returns true.Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
CI is sufficient.