Base: Enhance Bitmask with constexpr support and exhaustive tests#9
Base: Enhance Bitmask with constexpr support and exhaustive tests#9dragonfruit-blue wants to merge 1 commit intoswe-productivity:mainfrom
Conversation
40da41a to
5f83dfb
Compare
|
|
||
| // ---- Const correctness ------------------------------------------------------ | ||
|
|
||
| TEST_F(BitmaskTest, constCorrectness) |
There was a problem hiding this comment.
What is it we are testing here?
| } | ||
| constexpr bool operator!=(const Enum &f) const { | ||
| return i != f; | ||
| } |
There was a problem hiding this comment.
This is unnecessary -- we target C++23, which will autogenerate operator!=.
| @@ -18,14 +59,433 @@ class BitmaskTest: public ::testing::Test | |||
| // void TearDown() override {}; | |||
| }; | |||
|
|
|||
| TEST_F(BitmaskTest, toUnderlyingType) | |||
| // ---- Alternative underlying types ------------------------------------------- | |||
There was a problem hiding this comment.
This is probably a little under-tested still. With a longer type you're worried about truncation along some code path that didn't consider the use of something with so many bits available. It could be future work, but since this is all LLM-generated we may as well do it now.
|
|
||
| // Assert | ||
| EXPECT_EQ(typeid(result), typeid(int)); | ||
| TEST_F(BitmaskTest, testFlagAll) |
There was a problem hiding this comment.
This should probably also test the reverse (that is, make sure it returns false when NOT all the flags are set).
| EXPECT_TRUE(flags.testFlag(TestFlagEnum::Flag1)); | ||
| } | ||
|
|
||
| TEST_F(BitmaskTest, setFlagOnDefaultParamIsTrue) |
There was a problem hiding this comment.
How is this different from the test right above it (besides just testing a different flag)?
This PR modernizes the Base::Flags class with constexpr support, fixed operator!, and new operators (^, ^=, ==, !=). It also adds an exhaustive test suite in tests/src/Base/Bitmask.cpp to ensure robustness and prevent regressions.