def test_bit_count_zero_8(self):
     n = [
         ( 0, 8 ),
         ( 1, 7 ),
         ( 255, 0 ),
         ( 32768, 8 ),
         ( 32769, 7 ),
     ]
     for k, v in n:
         bi.int_to_bit(k, 8)
         self.assertEqual(bi.bit_count(k, 8, zero=True), v)
 def test_bit_count_32(self):
     n = [
         ( 0, 0 ),
         ( 1, 1 ),
         ( 255, 8 ),
         ( 32768, 1 ),
         ( 32769, 2 ),
     ]
     for k, v in n:
         bi.int_to_bit(k, 8)
         self.assertEqual(bi.bit_count(k, 32), v)
 def test_bit_count_zero_32(self):
     n = [
         ( 0, 32 ),
         ( 1, 31 ),
         ( 255, 24 ),
         ( 32768, 31 ),
         ( 32769, 30 ),
     ]
     for k, v in n:
         bi.int_to_bit(k, 8)
         self.assertEqual(bi.bit_count(k, 32, zero=True), v)
 def test_int_to_bit_8(self):
     n = [
         ( 0, "00000000" ),
         ( 1, "00000001" ),
         ( 0xff, "11111111" ),
         ( 0x8000, "00000000" ),
         ( 0x8001, "00000001" ),
     ]
     for k, v in n:
         ba0 = bytearray(2)
         self.assertEqual(bi.int_to_bit(k, 8), v)