def test_padding(self): self.assertEqual(int_to_bits(127), '01111111') self.assertEqual(int_to_bits(127, padding=2), '01111111') self.assertEqual(int_to_bits(127, padding=3), '001111111') self.assertEqual(int_to_bits(127, padding=5), '0001111111') self.assertEqual(int_to_bits(127, padding=6), '000001111111') self.assertEqual(int_to_bits(127, padding=7), '1111111')
def test_two_bytes(self): self.assertEqual(int_to_bits(256), '0000000100000000') self.assertEqual(int_to_bits(511), '0000000111111111')
def test_one(self): self.assertEqual(int_to_bits(1), '00000001')
def test_full_byte(self): self.assertEqual(int_to_bits(255), '11111111')
def test_zero(self): self.assertEqual(int_to_bits(0), '00000000')