Skip to content

Commit

Permalink
Fix bit count function
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed May 15, 2024
1 parent a440d07 commit bf3724a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/python_testing/TC_ICDM_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def is_valid_uint16_value(var):
def is_valid_uint8_value(var):
return isinstance(var, int) and 0 <= var <= 0xFF

def bit_count(self):
return bin(self).count("1")
@staticmethod
def set_bits_count(number):
return bin(number).count("1")

async def _read_icdm_attribute_expect_success(self, attribute):
return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute)
Expand Down Expand Up @@ -213,8 +214,8 @@ async def test_TC_ICDM_2_1(self):
uatHintInstructionDepedentBitmap = uat(
userActiveModeTriggerHint) & kUatInstructionDependentBitMask

asserts.assert_less_equal(
uatHintInstructionDepedentBitmap.bit_count(), 1, "UserActiveModeTriggerHint has more than 1 bit that is dependent on the UserActiveModeTriggerInstruction")
asserts.assert_less_equal(
self.set_bits_count(uatHintInstructionDepedentBitmap), 1, "UserActiveModeTriggerHint has more than 1 bit that is dependent on the UserActiveModeTriggerInstruction")

# Valdate UserActiveModeTriggerInstruction
self.step(9)
Expand Down

0 comments on commit bf3724a

Please sign in to comment.