MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_bit_count

Method test_bit_count

Lib/test/test_long.py:1179–1188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1177 self.assertEqual((-a-1).bit_length(), i+1)
1178
1179 def test_bit_count(self):
1180 for a in range(-1000, 1000):
1181 self.assertEqual(a.bit_count(), bin(a).count("1"))
1182
1183 for exp in [10, 17, 63, 64, 65, 1009, 70234, 1234567]:
1184 a = 2**exp
1185 self.assertEqual(a.bit_count(), 1)
1186 self.assertEqual((a - 1).bit_count(), exp)
1187 self.assertEqual((a ^ 63).bit_count(), 7)
1188 self.assertEqual(((a - 1) ^ 510).bit_count(), exp - 8)
1189
1190 def test_round(self):
1191 # check round-half-even algorithm. For round to nearest ten;

Callers

nothing calls this directly

Calls 4

bit_countMethod · 0.80
binFunction · 0.50
assertEqualMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected