Skip to content

Commit

Permalink
Fix type conversion error in BitFlags Clear (#30680)
Browse files Browse the repository at this point in the history
* attempt to fix failing CI

* added test for BitMask Clear function
  • Loading branch information
fessehaeve authored and pull[bot] committed Jan 12, 2024
1 parent 8655add commit 1037906
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/support/BitFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class BitFlags
*/
BitFlags & Clear(const BitFlags & other)
{
mValue &= ~other.mValue;
mValue &= static_cast<IntegerType>(~static_cast<IntegerType>(other.mValue));
return *this;
}

Expand Down
16 changes: 16 additions & 0 deletions src/lib/support/tests/TestBitMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,26 @@ void TestBitMaskInvalid(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, mask.Raw() == 0x1234);
}

void TestClear(nlTestSuite * inSuite, void * inContext)
{
BitMask<TestEnum> mask1;
BitMask<TestEnum> mask2;

mask1.Set(TestEnum::kBit_0);
mask1.Set(TestEnum::kBits_1_2);
mask1.Set(TestEnum::kBits_High8);

mask2.Set(TestEnum::kBits_1_2);
mask1.Clear(mask2);

NL_TEST_ASSERT(inSuite, mask1.Raw() == 0xFF01);
}

const nlTest sTests[] = {
NL_TEST_DEF("BitMask operations", TestBitMaskOperations), //
NL_TEST_DEF("BitFields logic", TestBitFieldLogic), //
NL_TEST_DEF("Invalid operations", TestBitMaskInvalid), //
NL_TEST_DEF("Clear operations", TestClear), //
NL_TEST_SENTINEL() //
};

Expand Down

0 comments on commit 1037906

Please sign in to comment.